Contents

Which of the following is the truncation division operator?
a) /                                                         
b) %
c) //                                                        
d) |

c

Explanation: // is the operator for truncation division. It is called so because it returns only the integer part of the quotient, truncating the decimal part. For example: 20//3 = 6.


What are the values of the following Python expressions?
a) 64, 512, 64                      
b) 64, 64, 64
c) 512, 512, 512  
d) 512, 64, 512

d

Explanation: Expression 1 is evaluated as 2**9, which is equal to 512. Expression 2 is evaluated as 8**2, which is equal to 64. The last expression is evaluated as 2**(3**2). This is because the associativity of ** operator is from right to left. Hence the result of the third expression is 512.


What is the value of the following expression?
a) (1.0, 4.0)                          
b) (1.0, 1.0)
c) (4.0. 1.0)                           
d) (4.0, 4.0)

a

Explanation: The above expressions are evaluated as: 2/2, 8/2, which is equal to (1.0, 4.0).


What is the value of the following expression?
a) 8                                                        
b) 8.0
c) 8.3                                     
d) 8.33

b

Explanation: The expression shown above is evaluated as: float( 7+1) = float(8) = 8.0. Hence the result of this expression is 8.0.


What will be the output of the following Python expression?
a) Error                                 
b) 1.0
c) 1.00                                   
d) 1

b

Explanation: The result of the expression shown above is 1.0 because print rounds off digits.


What will be the value of X in the following Python expression?
a) 30.0                                  
b) 30.8
c) 28.4                                   
d) 27.2

d

Explanation: The expression shown above is evaluated as: 2+9*(36-8)/10, which simplifies to give 2+9*(2.8), which is equal to 2+25.2 = 27.2. Hence the result of this expression is 27.2.