1: Which of the following will print “Hi Macquarie!” to the console?
20s
print("Hi", "Macquarie!")
print("Hi Macquarie!")
print("Hello Macquarie!")
"Hi Macquarie!".print()
2: Which loop structure should you use if you know in advance how many times you want to execute a block of code?
20s
while loop
for loop
do-while loop
repeat-until loop
3: How do you add an element 30 to the end of the list numbers, where numbers = [1, 2, 10, 27]
20s
numbers.append(30)
numbers.add(30)
numbers.push(30)
numbers.insert(30)
4: How do you exit a loop prematurely in Python?
20s
Using `return`
Using `break`
Using `continue`
Using `exit`
5: Which condition will evaluate to False?
20s
not []
True == 1
False == 0
1 == '1'
6: Consider the following 4 variables: (1, 2, 3); [1, 2, 3]; {1, 2, 3}; {"one": 1, “two”: 2, “three”: 3}. What are their data types in the order in which they are listed?
20s
tuple, list, set, dictionary
set, list, tuple, sequence
tuple, set, range, dictionary
list, tuple, sequence, dictionary
7: What will the following code output?
20s
0 1 2
1 2 3
0 1 2 3
It will result in an infinite loop.
8: What method removes the specified item from a dictionary and returns the value of the removed item?
20s
pop()
remove()
popitem()
extractitem()
9: Which of the following is a valid variable assignment in Python?
20s
int x = 10
x_2 = 10
x-2 = 10
2x = 10
10: Given the following Python code snippet, what will be the value of result once the loop concludes?
20s
1
24
8
48
11: In Python, which naming convention is typically used for variables?
20s
Snake case
Camel case
Pascal case
Kebab case
12: Which command lists installed Python packages?
20s
pip list
pip show
python packages
list pip
13: Evaluate the following: 0.3 == 0.1 * 3
20s
True
False
14: Which of the following correctly demonstrates inheritence in Python?
20s
class Parent: pass \n class Child(Parent): pass
class Parent: pass \n class Child: inherit Parent
class Parent: pass \n class Child inherits Parent: pass
class Parent: pass \n class Child extends Parent: pass