Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
123 views

Python - Sample Question

The document contains a 20 question sample computational Olympiad exam in Python. The questions cover Python syntax, functions, operators, data types, conditionals, and more. The key provided at the bottom indicates the correct answer for each multiple choice question.

Uploaded by

Anh Bùi Đông
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
123 views

Python - Sample Question

The document contains a 20 question sample computational Olympiad exam in Python. The questions cover Python syntax, functions, operators, data types, conditionals, and more. The key provided at the bottom indicates the correct answer for each multiple choice question.

Uploaded by

Anh Bùi Đông
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

HONG KONG INTERNATIONAL

COMPUTATIONAL OLYMPIAD
SAMPLE QUESTION – CÂU HỎI MẪU

Python Time allowed: 60 minutes

1. What is output of –
33 == 33.0
A. True
B. False
C. 33
D. Error
E. None of the above

2. What is output for −


b = [11,13,15,17,19,21]
ptint(b[::2])

A. [19, 21]
B. [11, 15]
C. [11, 15, 19]
D. [13, 17, 21]
E. [13, 17, 19, 21]

3. Analyze the given below code?

A. Recursive Function 24.


B. Recursive Function
C. Function runs infinitely and causes a StackOverflowError.
D. Syntax Error.
E. None of the above

4. What is the output of the following code?

A.6 B. 33 C.123 D.1+2+3


E. Error. Mixing operators between numbers and strings are not supported
5. What is the output of the following displayPerson() function call

A. Emma
25
B. name
age
C. 25
D. TypeError
E. None of the above

6. What is the output of the following function call

A. 5 B. 15 C. (15, 5) D. 10 E. Syntax Error

7. What is the output of print(2%6)


A. 0.33B. 2 C. 6 D. Value Error E. None of the above

8. How do you insert COMMENTS in Python code?


A. /*This is a comment*/
B. //This is a comment
C. #This is a comment
D. ‘This is a comment
E. None of the above
9. What is the output of the following code?

A. 20
B. 24
C. 30
D. 40
E. The program executed with errors

10. Jack executed the code with the python interpreter:

What is the output?


A. [‘Jon’, ‘Kelly’, ‘Jessa’, ‘Scott’]
B. [‘Jon’, ‘Kelly’, ‘Scott’, ‘Jessa’]
C. [‘Jon’, ‘Scott’, ‘Kelly’, ‘Jessa’]
D. [‘Scott’ ,‘Jon’, ‘Kelly’, ‘Jessa’]
E. The program executed with errors

11. What is the output of the following code?

A. jam
B. dno
C. dnoBsemaj
D. maj
E. james

12. What is the value of “Hello”.lower().capitalize() ?


A. “Hello”
B. “hello”
C. “HELLO”
D. Runtime Error
E. None of the above
13. Consider the following code,

What is the output?


A. True
B. False
C. 50
D. 100
E. None of the above

14. Which method can be used to remove any whitespace from both the beginning and the end of a string?
A. ptrim() B. trim() C. len() D. strip() E. None of the above

15. What is the output of the add() function call

A. 8 B. 15 C. (8, 7) D. Syntax Error E. None of the above

16. Which of the following is False?


A.
B.
C.
D. All of the above
E. None of the above

17. Choose the correct function declaration of fun1() so that we can execute the following function call
successfully

A. def fun1(*data)
B. def fun1(**kwargs)
C. def fun1(args*)
D. No, it is not possible in Python
E. None of the above
18. What is the output of the following code?

print(bool(0), bool(3.14159), bool(-3), bool(1.0+1j))

A. True True False True


B. False True True True
C. True True False True
D. False True False True
E. None of the above

19. What is the output of the following assignment operator:

A. 10
B. 12
C. 1
D. 2
E. Syntax Error

20. . Given the nested if-else above, what will x become after the above statement is executed

A. 0 B. 4 C. 2 D. 3 E. None of the above

~ End of Paper ~
KEY / ĐÁP ÁN

A B C D E A B C D E
1 ⚫ O O O O 11 O O O ⚫ O
2 O O ⚫ O O 12 ⚫ O O O O
3 O O ⚫ O O 13 O O ⚫ O O
4 O O O O ⚫ 14 O O O ⚫ O
5 O O O ⚫ O 15 O O ⚫ O O

A B C D E A B C D E
6 O ⚫ O O O 16 O O O O ⚫

7 O ⚫ O O O 17 ⚫ O O O O
8 O O ⚫ O O 18 O ⚫ O O O
9 O O ⚫ O O 19 O O O O ⚫

10 O O O O ⚫ 20 O O O ⚫ O

You might also like