HONG KONG INTERNATIONAL
COMPUTATIONAL OLYMPIAD
FINAL ROUND 2019 - 2020
Python
Time allowed: 90 minutes
Mock Paper
Instructions to Contestants:
1. Each contestant should have ONE Question-Answer Book which CANNOT be
taken away.
2. There are a total of 24 questions in this Question-Answer Book. Two points for
correct answers. No points for incorrect answers. ONE penalty point will be
deducted for incorrect answers.
3. All answers should be written on ANSWER SHEET.
4. During the contest, NO calculators can be used for Scratch and Blockly but
calculators can be used for Python.
5. All figures in the paper are not necessarily drawn to scale.
6. This Question-Answer Book will be collected at the end of the contest.
THIS Question-Answer Book CANNOT BE TAKEN AWAY.
DO NOT turn over this Question-Answer Book without approval of the examiner.
Otherwise, contestant may be DISQUALIFIED.
All answers should be written on the ANSWER SHEET.
Multiple Choice Questions (1st ~24th) (Two points for correct answers. No points for incorrect
answers. ONE penalty point will be deducted for incorrect answers.)
1. sum(set(map(lambda x: x % 3 == 0, range(30)))) evaluates to?
A. 1
B. 10
C. 11
D. 30
E. None of the above
2. Which of the following is a valid list?
A. [ 1 2 3 4 5 ]
B. [ a; b; c; d; e ]
C. [ *range(10) ]
D. [ True True False False True ]
E. None of the above
3. Which of the following is not a member of module time?
A. clock_gettime
B. ctime
C. gmtime
D. utctime
E. None of the above
4. The value of −10 // 3 * 4 is?
A. −13.2
B. −16
C. −120
D. −12
E. None of the above
5. The precision of [Link]() is?
A. depends on system implementation
B. 0.001 ms
C. 1 ms
D. 1 s
E. None of the above
6. [Link](1.0) suspend the calling thread for how long?
A. 0.001 second
B. 0.01 second
C. 0.1 second
All answers should be written on the ANSWER SHEET.
D. 1.0 second
E. None of the above
7. The value of (2,) == (2,) != [2,] is ?
A. True
B. False
C. None
D. Runtime Error
E. None of the above
8. The value of sum([a * 2 for a in range(10) if a % 2 == 0]) is?
A. 30
B. 40
C. 50
D. 60
E. None of the above
9. The output of the following code is?
class A:
x=3
def func(a):
print(a.x)
a = A()
a.x = 2
[Link] = func
[Link]()
A. 2
B. 3
C. runtime error
D. None
E. None of the above
10. What is the output of the following code?
sum = 0
for a, index in enumerate([4, 3, 2, 1]):
sum += a
print(sum)
All answers should be written on the ANSWER SHEET.
A. 6
B. 10
C. 16
D. 4
E. None of the above
11. What is the value of 0b10001?
A. 1
B. 17
C. 33
D. 65
E. None of the above
12. len([a for a in range(10) if a % 3 == 0]) is?
A. 0
B. 1
C. 2
D. 3
E. None of the above
13. The definition of func is as follow:
def func(a):
if a == 1:
return 1
elif a % 2 == 0:
return func(a / 2)
else:
return func(3 * a + 1)
What is the value of func(24)?
A. 24
B. 12
C. 6
D. 1
E. None of the above
14. Which of the following is a valid list?
A. list(1,3,2,5)
B. ([(3, ), (4, ), ],)
C. [1, 3+2, 7, 8]
D. list(*(4,2,3,))
E. None of the above
All answers should be written on the ANSWER SHEET.
15. Which of the following is a valid ternary if expression?
A. condition ? a : b
B. [] ? a : b
C. if []: a else b
D. a if condition else b
E. [a, b][condition]
16. What is the value of (lambda a, b=3: a ** b)(3) ?
A. 1
B. 3
C. 9
D. 27
E. None of the above
17. What is the output of the following code?
a = lambda b: b * 2
b = lambda c: a(c)
c=3
print(a(b(c)))
A. 2
B. 6
C. 12
D. 8
E. None of the above
18. Which of the following modules is used to create a virtual environment?
A. virtual_env
B. virtualenv
C. virevn
D. venv
E. None of the above
19. Which of the following programs is used to install packages?
A. package-install
B. pacman
C. yum
D. pip
E. None of the above
All answers should be written on the ANSWER SHEET.
20. The value of the following expression is?
(pi ** 2 / sqrt(pi) / sqrt(pi) / pi) == 1.00000001
A. True
B. False
C. Runtime error, number overflow
D. None
E. None of the above
21. Which of the following is a built-in function?
A. float
B. length
C. string
D. cast
E. None of the above
22. Which of the following is a built-in type?
A. bytearray
B. hex
C. Uint8Array
D. Exception
E. None of the above
23. print(f"{123456:02x}") would give?
A. 1e240
B. 123456
C. 1234
D. 3456
E. None of the above
24. The value of (complex(1, 2) * complex(1, -2)).real is?
A. −4
B. 1
C. 0
D. 5
E. 3
~ End of Paper ~