1. What is a variable
abstraction inside program that holds value>associated data storage that rep. single value at a time
2. What is the best type of data to represent someone's dog's name
variable
3. Why is it important to give variables specific names before containing values
call them while coding
4. What is the best way to print someone's phone number
string
5. Explain what an assignment operator is
the equal sign in coding
6. In Collegeboard pseudocode, what symbol is used to assign values to variables?
"<--"
7. 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 will display 22
8. What is a list
sequence of elements with each one (element) being a variable
9. What is an element
items in a list
10. What is an easy way to reference the elements in a list or string
11. What is an example of string
"Hello World"
thanksgivingList = ["cranberry pie", "casserole", "mashed potatoes", "turkey"]
print(thanksgivingList)
namelist = ["Luna", "Ethan", "Taiyo", "Parav", "Nikhil"]
# printing the end
print(namelist)
name = "Luna"
food = ["grapes", "apples","bananas"]
print(name, food)
food = ["grapes", "apples","bananas"]
print(food[1])
print(food[-1])
age = "16"
name = "Luna"
print(name + " is " + age)
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
numlist = [int(num1), int(num2), int(num3)]
# shows the original numbers to the user
print("Original->",numlist)
# add the new number to the original input
print("Add->",add)
# code that adds the inputted addend to the other numbers
for i in range(len(numlist)):
numlist[i -1] += int(add)
print("New->",numlist)
import getpass, sys
def question_with_response(prompt):
print("Question: " + prompt)
msg = input()
return msg
questions = 4
correct = 0
print('Hello, ' + getpass.getuser() + " running " + sys.executable)
print("You will be asked " + str(questions) + " questions.")
question_with_response("Are you ready to take a test?")
rsp = question_with_response("The purpose of lists and dictionaries are to manage the ____ of a program")
if rsp == "complexity":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is incorrect!")
rsp = question_with_response("Lists are a form of data ______")
if rsp == "abstraction":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is incorrect!")
rsp = question_with_response("Which brackets are used to assign values to a variable to make a list?")
if rsp == "[]":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is incorrect!")
print(getpass.getuser() + " you scored " + str(correct) +"/" + str(questions))
food1 = "pizza"
food2 = "hot dog"
food3 = "sushi"
food4 = "strawberry"
food5 = "sandwich"
print(food1, food2, food3, food4, food5)
food = ["pizza", "hotdog", "sushi", "strawberry", "sandwich"]
# change all the foods to share a list and use brackets
print(food)
color = ["red", "orange", "yellow", "green", "blue"]
# change all foods to color
print(color)