HONG KONG INTERNATIONAL
COMPUTATIONAL OLYMPIAD
HEAT ROUND 2019 - 2020 (HONG KONG REGION)
Python
Time allowed: 60 minutes
Question Paper
Instructions to Contestants:
1. Each contestant should have ONE Question-Answer Book which CANNOT be taken away.
2. There are a total of 20 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 PRIMARY GROUP but calculators can be used for
SECONDARY GROUP.
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.
Multiple Choice Questions (1st ~20th) (Two points for correct answers. No points for incorrect answers. ONE
penalty point will be deducted for incorrect answers.)
1. What is the purpose of in code like?
A. Aesthetic consideration
B. The code would not executed without this definition
C. Prevent main() from being executed when imported as module
D. It is a programming convention as main() also presented in other languages like C/C++ or Java
E. None of the above
2. Why can be executed without error but cannot?
A. Invalid type, number 2 is not a string
B. Argument “output” for function print() only accepts list
C. end = “2” is omitted by print() function
D. All of the above
E. None of the above
3. Does the following code have errors during execution? If so, what is it?
A. No, the code doesn‟t have errors
B. Yes, unidentified syntax (semicolon)
C. Yes, integer cannot add with float
D. Yes, expression a + b does not have a left hand side operator
E. None of the above
4. What is the expected output of the following code?
A.
B.
C.
D.
E. None of the above
5. What is the expected output of the following code?
A. abcd
B. dbce
C. edcb
D. dcea
E. None of the above
6. What is the value of ?
A. 0
B. 10
C. 170
D. 495
E. None of the above
7. The following code produces runtime error,
What is the cause the interpreter would show?
A. Argument type for func() is indeterminate
B. Return type for func() is indeterminate
C. Unsupported operand types for „+‟
D. main() arguments is not supported
E. None of the above
8. What could be filled in place of line 4 in the following code (indicated with comments) so that the expected
output is ?
A.
B.
C.
D.
E. None of the above
Refer to the following code for question 9 to 11:
There could be different implementations of fib method:
I.
II.
III.
IV.
9. Which implementation is fastest?
A. I
B. II
C. III
D. V
E. They have the same performance
10. Which implementation(s) consumes most memory during execution?
A. I & II
B. I
C. II & III
D. IV
E. No memory is needed at all
11. Implementation I doesn‟t use for-loop, implementation II doesn‟t use if, implementation III doesn‟t invoke
itself, implementation IV invoke itself once in each iteration. Which of the following is a correct statement?
A. Implementation without for-loop is always the fastest
B. Implementation with less memory usage is always the fastest
C. Shorter the implementation, faster the execution
D. Recursion is always the fastest
E. None of the above
12. What is the expected output of the following code?
A.
B.
C.
D.
E.
Refer to the following code for question 13 to 15:
13. Which of the following is a correct statement describing the relationship of class A, B and C?
A. Class A inherits class B and C and invoking initializer of parent class B
B. Class B and C inherits class A and both class implicitly invoke initializer of class A
C. Class C is a subclass of class B and both are subclass of class A
D. The code is not correct and would produce syntax error
E. None of the above
14. What is the expected output of the code?
A.
B.
C.
D. The code has runtime error
E. None of the above
15. What is “c” in line 8 is? And “self.c” in line 10?
A. Empty variable, integral variable
B. Class variable, instance variable
C. Member variable, constructor variable
D. The code is not correct syntax-wise
E. None of the above
16. What is the expected output of the following code?
A.
B.
C.
D.
E. None of the above
Refer to the following code for question 17 to 18:
17. Expression in line 8 evaluates to? If False, what is the reason they are not equal?
A. True
B. False, new list instances are created (and returned) each time func is invoked
C. False, variable i is modified between two func call so the values in the list are not the same
D. The code would result in runtime error
E. None of the above
18. What is the value of b in line 11?
A.
B.
C.
D.
E. None of the above
19. Given the code:
Which of the following is equivalent to the expression ?
A.
B.
C.
D. All of the above
E. None of the above
20. Given the code:
And its output :
What is the value of the expression ? If False, what is the appropriate reason?
A. True
B. False, list a is consumed but b is not, because list a is not explicit
C. False, every instances of list does not equal (evaluate to True) in case of „==‟ operator
D. False, values of elements are not equal in list a and b, they appear to be the same when printed out
E. None of the above
~ 全卷完 ~
~ End of Paper ~