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: -9 C: -1 E: 1 G: 9
B: -3 D: 0 F: 3 H: Error
P2 What is the output of this code?
A: -1 C: 100 E: 385 G: 3355 K: 28500
B: 10 D: 285 F: 2850 H: 7495 L: 29410
1
P3 What is the output of this code?
A: -1 C: 1 E: 1.14 G: 3.14 K: 11.3
B: -0 D: 0.32 F: 2.29 H: 9.87 L: Error
P4 What is the output of this code?
A: 1 C: 2 E: 3 G: 4 K: 5
B: 1.5 D: 2.5 F: 3.5 H: 4.5 L: 5.5
P5 What is the output of this code?
A: -6 C: -2 E: 0 G: 2 K: 6
B: -5 D: -1 F: 1 H: 5 L: Error
2
P6 What complexity does the Insertion Sort 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
C
5
E
6
G
7
P8 What complexity does the insertion in doubly-linked list have in the worst case?
Answer must contain: (time complexity / space complexity).
A: O(1) / C: O(log(n)) / E: O(n) / G: O(1) / K:
O(1) O(1) O(1) O(n) O(log(n))) /
O(n)
B: O(n) / D: O(1) / F: O(log(n)) / H: O(n) / L: O(n) /
O(n) O(n log(n))) O(n log(n))) O(n log(n))) O(n)
P9 What is the output of this code?
A: -720 C: -24 E: -15 G: -1 K: 1 M: 15 P: 24 R: 720
B: -120 D: -18 F: -11 H: 0 L: 11 N: 18 U: 120 S: Error
8
P10 Which of the following variables are True?
A: a C: c E: e G: g K: a, b M: e, f P: a, c R: e, g T: all
B: b D: d F: f H: h L: c, d N: g, h U: b, d S: f, h W: no
9
Correct Answers:
1 2 3 4 5 6 7 8 9 10
F F H F D K C G U A
10