simplified food list:
lists are better because it makes your code sorter and more efficient

foods = ['pizza, hotdog, sushi, strawberry, sandwich']
print(foods)
['pizza, hotdog, sushi, strawberry, sandwich']
color1 = "red"
color2 = "orange"
color3 = "yellow"
color4 = "green"
color5 = "blue"
color6 = "indigo"
color7 = "violet"
print(color1, color2, color3, color4, color5, color6, color7)

color = ['red, orange, yellow, green, blue, indigo, violet']
print(color)
red orange yellow green blue indigo violet
['red, orange, yellow, green, blue, indigo, violet']
num1=input("Input first number. ")
num2=input("Input second number. ")
num3=input("Input third number. ")
add=input("How much would you like to add to each number? ")

# Add code in the space below

num1 = int(num1)
num2 = int(num2)
num3 = int(num3)
numlist = [num1 , num2, num3]

# The following is the code that adds the inputted addend to the other numbers. It is hidden from the user.

for i in numlist:
    numlist[i -1] += int(add)

print(numlist)
[2, 3, 4]
  • Create a list with indices
  • Index a part of the list that you created.
  • Try to index from the end ### index dog from front and end
petsList = ["cat", "dog", "fish", "bird"]
print(petsList)

print(petsList[1]) 
print(petsList[-3]) 
['cat', 'dog', 'fish', 'bird']
dog
dog

What is a list?

  • A list of values or variables that can be assigned all at once

What is an element

  • the things in a list

What is an easy way to reference the elements in a list or string?

  • print(name of list)

What is an example of a string?

  • hello

Create an index of your favorite foods

favFood = ["sushi", "pasta", "strawberries", "tiramisu", "potato"]
print(favFood)
in1 = input("Input number")
print(favFood[int(in1)-1])
['sushi', 'pasta', 'strawberries', 'tiramisu', 'potato']
sushi

In your own words, briefly explain by writing down what an assignment operator is

  • an operator that assigns values to variables

In Collegeboard pseudocode, what symbol is used to assign values to variables?

  • -> an arrow

A variable, x, is initially given a value of 15. Later on, the value for x is changed to 22. If you print x, would the command display 15 or 22?

  • if you print x it would display 22 because code is read from top to bottom and meaning if the variable is reassigned later on in the code, the reassigned value will be the one that is displayed
print("name:")
name = input("what's your name?")
print("my name is", name)

print("age:")
age = input("how old are you?")
print("I am", age, "years old")

print("phone number:")
phoneNumber = input("what's your phone number")
print("my phone number is", phoneNumber)
name:
my name is claire
age:
I am 16 years old
phone number:
my phone number is 8582394568