You are on page 1of 5

Test 2: Expressions

 L2.1. Choose the best statement about a CONSTANT in Python?

a. Its name usually in UPPER cases (e.g., PI, MAX, etc.)

b. All statements are correct

c. It could be assigned a numeric value (e.g., -2, or 9, or 3.14)

d. Its value does not change

e. Its value could be a string constant (e.g., 'Hello World')

 L2.2. Which statement is NOT correct about key words in Python?

a. break, continue are NOT keywords

b. if, for, while, import, raise are keywords

c. A variable/constant must be different from keywords

d. A keyword is occupied by the inventor of programming language

 L2.3. Choose the best statement about a VARIABLE in Python?

a. It is a named place in the memory where a programmer can store and retrieve data

b. Its value may be changed within the program

c. It could be assigned a numeric value (e.g., -2, or 9, or 3.14), or a string value (e.g.,
'Hello World')

d. All statements are correct

 L2.4. Choose the best answer, which are valid VARIABLE names in Python?

a. All statements are INCORRECT

b. 23_spam

c. spam, spam23, _spam

d. #spam

 L2.5. What terminology is used to call "input('Enter your name, please!')"?

a. Variables

b. Assignment statement

c. Functions
d. Operators

 L2.6. Which terminology is used to call 'print' in the statement "print(x + 3)"?

a. Modules

b. Libraries

c. Functions

d. Variables

 L2.7. Which terminology is used to call 'x+3' in the statement "print(x + 3)"?

a. Arguments

b. Libraries

c. Variables

d. Functions

 L2.8. Which terminology is used to call '==' in the statement "x == 3"?

a. Operators

b. Functions

c. Variables

d. Assignment statement

 L2.9. Which terminology is used to call 'pow' in the statement "x = pow(4, 3)"?

a. Built-in functions

b. Expressions

c. Submodules

d. User-defined functions

 L2.10. What is the value of x after being evaluated: x = 1 + 2 * 3 - 50 / 5 ** 2

a. -43

b. 5

c. -93

d. Error because '**' is an invalid operator in Python


 L2.11. What is correct about the operator precedence rules in Python? (choose the best
answer)

a. Parenthesis > Multiplication > Power > Left to Right > Addition

b. Parenthesis > Power > Multiplication > Addition > Left to Right

c. Power > Parenthesis > Multiplication > Addition > Left to Right

d. Parenthesis > Multiplication > Power > Addition > Left to Right

 L2.12. What is the output of the following code?

a. 36 0

b. 66 0

c. 66 3

d. 36 3

 L2.13. What is the output of 'print(2 ** 3 ** 2)'?

a. 64

b. Error because '**' is not a valid operator in Python

c. 512

d. It depends on computers

 L2.14. What is the output of the following code?

a. It depends on computers

b. Syntax error because it is invalid in Python


c. 10

d. 12

 L2.15. What is the output of 'print(2 * 3 ** 2 * 4)’

a. Error because '**' is not a valid operator in Python

b. Syntax Error

c. 72

d. 48

 L2.16. What is the output of 'print(2%6)’

a. 2

b. 0.33

c. ValueError

 L2.17. What is the value of the following code 'print(36 / 4)’

a. 9.0

b. 9

 L2.18. What is the output of the following code: 'print(9//2)’

a. 4.5

b. Error

c. 4.0

d. 4

 L2.19. What is the output of the following code?

a. 1 0 2 4 3 5

b. 0 1 2 3 4 5

c. Error because there is no '++' operator in Python


d. 0 2 1 3 2 4

 L2.20. What is the maximum possible length of an identifier?

a. 64

b. 256

c. The maximum possible length of an identifier is not defined in the python language.
It can be of any number.

d. 128

You might also like