WorksheetsCS 1 Cycle 3 exam
Total questions: 30
Worksheet time: 30mins
What will print when this code executes?
<class 'tuple'>
<class 'list'>
<class 'set'>
<class 'dict'>
What will print when this code executes?
<class 'tuple'>
<class 'list'>
<class 'set'>
<class 'dict'>
<class 'int'>
What will print when this code executes?
<class 'tuple'>
<class 'list'>
<class 'set'>
<class 'dict'>
<class 'int'>
What will print when this code executes?
<class 'tuple'>
<class 'list'>
<class 'set'>
<class 'dict'>
<class 'int'>
Which of the following statements correctly describes the mutability of lists and tuples in Python?
Lists are immutable, while tuples are mutable.
Lists are mutable, while tuples are immutable.
Both lists and tuples are mutable.
Neither lists nor tuples are mutable.
What will print when this code executes?
3
6
8
10
9
What will print when this code executes?
1
4
7
6
9
What will print when this code executes?
[4, 5, 6]
[7, 8, 9]
7
2
[10, 11, 12]
What will print when this code executes?
[4, 5, 6]
[7, 8, 9]
7
2
[10, 11, 12]
Which of the following code snippets will print 5 to the screen, given this list:
my_list=[[2,4,6,8],[1,3,5,7],[0,10,20,30]]
print(my_list[1][2])
print(my_list[0][2])
print(my_list[2][0])
print(my_list[1][1])
print(my_list[0][1])
Which of the list below has the dimensions of 3 X 2 X 3?
Which of the list below has the dimensions of 9 X 2?
Which of the list below has the dimensions of 3 X 4 ?
Who is known as the Father of the Computer?
Alan Turing
Charles Babbage
Grace Hopper
Ada Lovelace
Tim Berners-Lee
Who is known as the First Programmer?
Alan Turing
Charles Babbage
Grace Hopper
Ada Lovelace
Tim Berners-Lee
Who is known as the Queen of Software?
Alan Turing
Charles Babbage
Grace Hopper
Ada Lovelace
Tim Berners-Lee
Who is known as the Father of Computer Science?
Alan Turing
Charles Babbage
Grace Hopper
Ada Lovelace
Tim Berners-Lee
Who is known as the Inventor of the World Wide Web?
Alan Turing
Charles Babbage
Grace Hopper
Ada Lovelace
Tim Berners-Lee
What will be the output to the console for the code below?
for i in range(1,4):
print(i)
1
2
3
1
2
3
4
0
1
2
3
0
1
2
3
4
Which of these will allow me to count from 0-20 in steps of 5?
for x in range(0,20):
print(x)
while x = (0,20,5):
print(x)
for x in range(0,21,5):
print(x)
for x in range(0,21,5):
print(y)
Which of the following best describes the Python def keyword
It's used to defined a class
It's used in conditional statements
It's used to define a function
It's used to delete an object
What will be the output for the program above?
<class 'tuple'>
<class 'list'>
<class 'set'>
<class 'dict'>
Which value is a String?
64
"cat"
True
0.5
Which of these pieces of code would return the name "Isabel" from the following list?
nameList = ["Pedro", "Alex", "Evelyn", "Isabel", "Diego", "Shawn"]
nameList(3)
nameList[3]
NameList["Isabel"]
name[3]
What kind of data structure is user_data in the following declaration?
user_data = {"name": "TJ", "age":24, "user_name":"artLover123"}
List
Tuple
Range
Dictionary
Which of the following code snippets will create this 2D list?
[
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]
board = [1, 2, 3] + [4, 5, 6] + [7, 8, 9]
board = [1, 2, 3]
board.append([4, 5, 6])
board.append([7, 8, 9])
board = [1, 2, 3, 4, 5, 6, 7, 8, 9]
board = []
board.append([1, 2, 3])
board.append([4, 5, 6])
board.append([7, 8, 9])
What does “packing” refer to in Python?
Creating a list
Initializing variables using values from a list
Storing multiple variables’ values by putting them in a collection, like a list or tuple
Cramming as many commands as possible onto a single line
What does “unpacking” refer to in Python?
Initializing multiple variables at a time using a collection of values
Storing multiple variables’ values by putting them in a collection, like a list or tuple
Cramming as many commands as possible onto a single line
Creating a list
Which of the following assignment statements is equivalent to the following code snippet?
red, blue, green = "BLUE", "GREEN", "RED"
red = "BLUE"
blue = "GREEN"
green = "RED"
red = ["BLUE", "GREEN", "RED"]
blue = ["BLUE", "GREEN", "RED"]
green = ["BLUE", "GREEN", "RED"]
red = "RED"
blue = "BLUE"
green = "GREEN"
red = "BLUE"
blue = "BLUE"
green = "BLUE"
What is the output of this program?
tree
flower
weed
tree : oak
flower : daisy
weed : bindweed
oak
daisy
bindweed
tree oak
flower daisy
weed bindweed
