Unit 3.1-3.3 Hacks

name = "alex"
age = 16
print("name is", name)
print("age is", age)

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

  • an equal sign is an assignment operator as it assigns a variable to a value In Collegeboard pseudocode, what symbol is used to assign values to variables?
  • the arrow is used to assign values 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?
  • it would output 22

What is a list?

  • a bundle of multiple elements What is an element
  • an element could be a number or integer, string, or a boolean expression What is an easy way to reference the elements in a list or string?
  • use index to find the elements in a list What is an example of a string?
  • “amay” this is an example of a string
    foods = ["pizza", "chicken", "steak", "pasta", "lasagna", "salad", "burger"]
    print(foods[3])
    print(foods[-4])
    
    num1=input("Input a number. ")
    num2=input("Input a number. ")
    num3=input("Input a number. ")
    add=input("How much would you like to add? ")
    # Add code in the space below
    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 [int(a) for a in numlist]:
      numlist[i -1] += int(add)
    print(numlist)
    

    foods = ["pizza", "hot dog", "sushi", "strawberry", "sandwhich"] #simplified foods list
    # it is better to use lists because it is more simple
    sports1 = "basketball"
    sports2= "tennis"
    sports3 = "soccer"
    sports= ["basketball","tennis","soccer"]