46). The value of the expressions 4/(3*(2-1)) and 4/3*(2-1) is the same.
[A]True
[B]False
[C]none
[D]none of the mentioned
Show Answer
Correct Answer: True
Notes:
Answer: a
Explanation: Although the presence of parenthesis does affect the order of precedence, in the case shown above, it is not making a difference. The result of both of these expressions is 1.333333333. Hence the statement is true.
47). What will be the value of the following Python expression?
4 + 3 % 5
Show Answer
Correct Answer: 7
Notes:
Answer: b
Explanation: The order of precedence is: %, +. Hence the expression above, on simplification results in 4 + 3 = 7. Hence the result is 7.
48). Evaluate the expression given below if A = 16 and B = 15.
A % B // A
Show Answer
Correct Answer: 0
Notes:
Answer: b
Explanation: The above expression is evaluated as 16%15//16, which is equal to 1//16, which results in 0.
49). Which of the following operators has its associativity from right to left?
A % B // A
Show Answer
Correct Answer: **
Notes:
Answer: d
Explanation: All of the operators shown above have associativity from left to right, except exponentiation operator (**) which has its associativity from right to left.
50). What will be the value of x in the following Python expression?
x = int(43.55+2/2)
Show Answer
Correct Answer: 44
Notes:
Answer: b
Explanation: The expression shown above is an example of explicit conversion. It is evaluated as int(43.55+1) = int(44.55) = 44. Hence the result of this expression is 44.
51). What is the value of the following expression?
2+4.00, 2**4.0
[A](6.0, 16.0)
[B](6.00, 16.00)
[C](6, 16)
[D](6.00, 16.0)
Show Answer
Correct Answer: (6.0, 16.0)
Notes:
Answer: a
Explanation: The result of the expression shown above is (6.0, 16.0). This is because the result is automatically rounded off to one decimal place.
52). Which of the following is the truncation division operator?
2+4.00, 2**4.0
Show Answer
Correct Answer: //
Notes:
Answer: 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.
53). What are the values of the following Python expressions?
2**(3**2)
(2**3)**2
2**3**2
[A]64, 512, 64
[B]64, 64, 64
[C]512, 512, 512
[D]512, 64, 512
Show Answer
Correct Answer: 512, 64, 512
Notes:
Answer: 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.
54). What is the value of the following expression?
8/4/2, 8/(4/2)
[A](1.0, 4.0)
[B](1.0, 1.0)
[C](4.0. 1.0)
[D](4.0, 4.0)
Show Answer
Correct Answer: (1.0, 4.0)
Notes:
Answer: a
Explanation: The above expressions are evaluated as: 2/2, 8/2, which is equal to (1.0, 4.0).
55). What is the value of the following expression?
float(22//3+3/3)
[A]8
[B]8.0
[C]8.3
[D]8.33
Show Answer
Correct Answer: 8.0
Notes:
Answer: 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.