Python Modules Summary Test
Python Modules Summary Test
1. What do you call a file containing a program written in a high-level programming language?
a. A source file
b. A target file
c. A machine file
d. A code file
1. What is the output of the following snippet if the user enters two lines containing 2 and 4
respectively?
b. 8.0
c. 4.0
d. 2.0
2. What is the output of the following snippet if the user enters two lines containing 2 and 4
respectively?
a. 6
b. 2
c. 24
d. 4
3. What is the output of the following snippet if the user enters two lines containing 2 and 4
respectively?
a. 24
b. 2
c. 4
d. 6
a. 8
b. 17
c. 17.5
d. 8.5
5. What is the output of the following snippet if the user enters two lines containing 11 and 4
respectively?
a. 2
b. 4
c. 1
d. 3
a. 1 2
b. 1 1
c. 2 1
d. 2 2
7. What is the output of the following snippet if the user enters two lines containing 3 and 6
respectively?
a. 18
b. 666
c. 333333
d. 36
8. Left-sided binding determines that the result of the following expression:
a. 4.5
b. 0.0
c. 0
d. 0.166666666666666
9. The ** operator:
b. performs exponentiation
a. cannot be evaluated
b. is equal to 1.0
c.is equal to 1
d. cannot be predicted
12. What is the output of the following snippet if the user enters two lines containing 2 and 4
respectively?
a. 4.0
b. 8.0
c. 2.0
a. 1 1 1
b. 1 * 1 * 1
c. x*y*z
d. x y z
a. its value
17. Which of the following variable names are illegal? (Select two answers)
a. true
b. True
c. TRUE
d. and
a. 17
b. 25
d. 17.0
19. The value twenty point twelve times ten raised to the power of eight should be written as:
a. 20E12.8
b. 20.12E8
c. 20.12*10^8
d.20.12E8.0
20. The 0o prefix means that the number after it is denoted as:
a. hexadecimal
b. decimal
c. octal
d.binary
Module 3- Test
a. [1, 2, 3, 3, 2, 1]
b. [1, 1, 1, 1, 2, 3]
c. [1, 2, 3, 1, 2, 3]
d. [3, 2, 1, 1, 2, 3]
a. 0
b. 2
c. the snippet will cause a runtime error
d. 1
a. 7
b. 02
c. 4
d. 6
4. How many hashes (#) will the following snippet send to the console?
a. zero
b. two
c. three
d. one
5. An operator able to check whether two values are equal is coded as:
a. ==
b. !=
c. ===
d. =
6. What value will be assigned to the x variable?
a. 1
b. 0
c. True
d. False
a. 1
b. 0
c. 2
d. 3
9. After the execution of the following snippet, the sum of all vals elements will be equal to:
a. 5
b. 4
c. 2
d. 3
10. What is the output of the following snippet?
a. [2, 3, 4]
b. [2, 3]
c. [2]
d. []
11. How many stars (*) will the following snippet send to the console?
a. one
b. three
c. zero
d. two
12. Which of the following sentences are true? (Select two answers)
13. Take a look at the snippet, and choose the true statements. (Select two answers)
14. How many hashes (#) will the following snippet send to the console?
a. zero
b. two
c. one
d. Three
15. How many stars (*) will the following snippet send to the console?
a. zero
b. two
c. three
d. one
a. [3, 2, 1]
b. [3, 3, 3]
c. [1, 1, 1]
d. [1, 2, 3]
a. four
b. one
c. three
d. two
a. 1
b. -2
c. -1
d. 3
19. How many hashes (#) will the following snippet send to the console?
a. eight
b. two
c. one
d. four
20. The value eventually assigned to x is equal to:
a. 1
b. False
c. True
d. 0
Module 4 – Test
a. will output 4
b. will output 2
c. will return None
d. is erroneous
2. What is the output of the following snippet?
b. 2
c. None
d. 4
a. 3
b. the code is erroneous
c. 1
d. 6
5. What is the output of the following snippet?
a. (2,1)
b. (2)
c. 2
a. 2
b. 6
c. the snippet is erroneous
d. 4
8. Which of the following lines property starts a function using two parameters, both with zeroed
default values?
d. fun fun(a=0,b):
a. 2
b. None
d. 1
a. is erroneous
b. will output 2
c. will output 16
d. will output 4
a. 3
b. 0
c. 9
a. 22
b. 11
c. 21
d. 12
15. What code would you insert instead of the comment to obtain the expected output?
Expected output:
Code:
Ans: print(k[0])
16. Which of the following statements are true? (Select two answers)
17. Assuming that my_tuple is a correctly created tuple, the fact that tuples are immutable means
that the following instructions:
a. is fully correct
b. is illegal
d. can be executed if and only if the tuple contains at least two elements
18. What is the output of the following snippet?
b. two
c. one
d. three
b. 3
c. 4
d. 6
a. fun function( ):
b. def fun():
c.def fun:
d. function fun( ):
Part 1 Summary Test
a. two
b. zero
c.one
d. three
a. 2
b. 0
c.1
3. What is the output of the following piece of code if the user enters two lines containing 3 and 2
respectively?
a. 1
b. 0
c.3
d. 2
4. What is the output of the following piece of code if the users enter two lines containing 2 and 4
respectively?
a. 4.0
b. 1.0
C.0.0
d. 2.0
a. 4
b. 6
C.2
a. 1 1
b. 0 1
C.0 0
d. 1 0
a. 4
b. 44
C.(4)
d. (4,)
8. Which of the following sentences are true about the code? (Select two answers)
a. True
b. False
C. 0
d. 1
a. 1 1 2
b. 1 2 1
c. 2 1 2
d. 1 2 2
11. Take a look at the snippet and choose the true statement:
12. Which of the following variable names are illegal and will cause the SyntaxError exception?
(Select two answers)
a. print
b. In
c. for
d. in
13. Assuming that my_tuple is correctly created tuple, the fact that tuples are immutable means
that the following instruction:
a. is fully correct
b. can be executed if and only if the tuple contains at least two elements
c. is illegal
a. [1, 4, 9, 16]
b. [0, 1,9,16]
c. [0,1,4,16]
d. [0,1,4,9]
15. Which of the following lines correctly invoke the function defined below? (Select two answers)
a. fun ( 0, 1, 2)
b. fun ( b =1)
c. fun()
d. fun (b = 0, a = 0)
a. 1
c. 2None
d. 2
a. 0.0
b. 0.4
c. 0.2
d.0
a. be predicted
b. is equal to 0.5
c. is equal to 0
D. is equal to 0.0
19. The following snippet:
a. will output 4
b. will output 2
c. will output 0
d. is erroneous
20. How many stars ( *) will the following snippet send to the console?
a. two
b. zero
c. the snippet will enter an infinite loop, printing one star per line
d. one
a. asepbsepc
b. asepbsepcsep
c. a b c
d. abc
22. How many hashes ( # ) will the following snippet send to the console?
a. zero
b. three
c. nine
d. Six
23. An operator able to check whether two values are not equal is coded as:
a. <>
b. !=
c. not ==
d.=/=
a. its value
25. What is the output of the following piece of code if the user enters two lines containing 3 and 6
respectively?
a. 6
b. 36
c. 3
d. 63
a. [1,2,2,2]
b. [1,1,1,2]
c. [2,1,1,2]
d.[1,2,1,2]
27. What is the output of the following snippet?
a. (‘one’,’two’,’three’)
b. one
c. three
d.two
a. 0 1
c.1 0
d.0 0
a. (1, 2)
b. 12
c.21
d.(2,1)
30. The following snippet:
a. will output 2
c. will output 16
d.will output 4