Programming Problems: Python
General note:
The following code is executed as the first cell of the notebook in which all other
problems’ codes are run.
P1. What is the output of this code?
A: 0 C: 2 E: 4 G: 8 K: 12
B: 1 D: 3 F: 6 H: 10 L: 18
P2 What is the output of this code?
A: 0 C: 2 E: 59 G: 67 K: 99
B: 1 D: 3 F: 63 H: 69 L: ValueError
1
P3 What is the approximate output of this code?
A: 0 C: 2 E: π G: 2 π K: 10000
B: 1 D: 3 F: 4 H: 4 π L: ValueError
P4 What is the output of this code?
A: π / 8 C: 1 E: π G: 4 π K: 42
B: π / 4 D: π / 2 F: 2 π H: 8 π L: ValueError
2
P5 What is the output of this code?
A: 5 C: 11 E: 16 G: 20 K: 37
B: 7 D: 12 F: 17 H: 21 L: ValueError
P6 What complexity does the Mergesort algorithm have in the worst case?
Answer must contain: (time complexity / space complexity).
A: O(n) / C: O(log(n)) / E: O(n log(n)) / G: O(n log(n^2)) / K: O(n^2) /
O(1) O(1) O(1) O(1) O(1)
B: O(n) / D: O(log(n)) / F: O(n log(n)) / H: O(n log(n^2)) / L: O(n^2) /
O(n) O(n) O(n) O(n) O(n)
P7 What is the output of this code?
3
A
4
B
5
C
6
D
7
E
8
F
9
G
10
H
11
P8 Which figure represents a doubly linked list?
A
12
B
13
C
14
D
15
P9 What is the output of this code?
A: 11 C: 15 E: 17 G: 20 K: 32
B: 13 D: 16 F: 19 H: 25 L: ValueError
16
P10 What is the output of this code?
A B
C D
17
E F
G H
K L
M N
18
Correct Answers:
1 2 3 4 5 6 7 8 9 10
G G C B E F E C C A
19