WorksheetsUnit 8
Total questions: 7
Worksheet time: 5mins
Which of the following programs would produce the following output:
my_list = ["honey", "bread", "jelly", "plates"]
for index in range(len(my_list)): print(str(index) + ". " + my_list)
my_list = ["honey", "bread", "jelly", "plates"]
for index in range(len(my_list)): print(str(index+1) + ". " + my_list[index])
my_list = ["honey", "bread", "jelly", "plates"]
for index in my_list: print(str(index+1) + ". " + my_list[index])
my_list = ["honey", "bread", "jelly", "plates"]
for index in len(my_list): print(str(index) + ". " + my_list[index])
What kind of data structure is user_data in the following declaration?
user_data = ["TJ", 24, "artLover123"]
Tuple
List
2D List
String
Which of the following lines of code will cause an error? Use the following definition of ages:
ages = (12, 5, 8)
ages = ages + (1, 3, 5)
ages = ages + (1, 3, 5)
print(ages[2])
ages = ages[2:]
ages[0] = 3
What does this code snippet print?
fruit = ["b", "n", "n"]
print("a".join(fruit))
bnn
bnn
ba na na
banan
bbb
What is the value of num after this code runs?
shapes = ["triangle", "square", "hexagon", "circle", "pentagon"]
num = len(shapes)
0
4
5
33
What does this program print?
My favorite animal is a dog or penguin
My favorite animal is a penguin or chipmunk
What will be the output of the following program?
[1, 2, 3, 4, 5, 5, 5, 5]
[1, 2, 3, 4, 5]
[1, 2, 3, 4, 6, 7, 8, 9]
[1, 2, 3, 4, 5, 6, 7, 8]
