Font size
WorksheetsSecond Day Quiz!
Total questions: 11
Worksheet time: 8mins
Which one below is a list?
list
2
["hi", "I", "Am", "Bernard"]
(1, 2, 3)
{1: "1", 2: "2", 3: "3"}
a = [9, 3, 23, 84]
print(a[i])
what should be the value of i in order to get 23?
0
1
2
4
What is the main difference between a list and a tuple?
Tuple is slower, list is faster
Tuple is uglier, list is prettier
Tuples take less space than lists
A tuple is mutable, while a list is immutable
fav_foods = {"Japanese": "Sushi", "Chinese": "Chicken Rice", "Malay": "Nasi Lemak", "Indian": "Roti Canai"}
How do I get my favorite Malay food from this dictionary?
fav_foods[2]
fav_foods[3]
fav_foods["Nasi Lemak"]
fav_foods["Malay"]
What's wrong with this?
b = [[1,2,3], [4,5,6]]
It has two list in a list
it doesn't have semicolon at the end lol
Nothing's wrong
b is a bad name
How do I change the value of the first element into "D"?
a = ["A", "B", "C"]
a = "D"
a[0] = "D"
a["A"] = "D"
a[1] = "D"
what will happen?
a = 5
del a
print(a)
5 will be printed out
del is not defined before
will raise a definition error saying that a is undefined
a has been deleted but it can still be printed out
Which of the following statements are right?
Python is a language that's based on indentation to classify "blocks"
Condition can either be True or False
The "Blocks" inside if and while loop will only run when their conditions are True
for loop will run for a specified time, but while loop will run as long as the condition is true
what will be printed?
(a)
a = 0
for i in range(999):
a += 1
What is a after the for loop?
999
998
1000
1001
What is this?
The money will decrease by 1 at the start of the loop, and increase by 40 at the end of the loop because the keyword continue asks the program to continue after line 7
The loop will always print "I still have money!"
The loop will keep decreasing the money by 1, it wouldn't run the code after line 8 because of continue, but when the money is less than 10 it will increase by 40
money is infinity
