11). Which is the correct operator for power(xy)?
[A]X^y
[B]X**y
[C]X^^y
[D]None of the mentioned
Show Answer
Correct Answer: X**y
Notes:
Answer: b
Explanation: In python, power operator is x**y i.e. 2**3=8.
12). Which one of these is floor division?
[A]/
[B]//
[C]%
[D]None of the mentioned
Show Answer
Correct Answer: //
Notes:
Answer: b
Explanation: When both of the operands are integer then python chops out the fraction part and gives you the round off value, to get the accurate answer use floor division. This is floor division. For ex, 5/2 = 2.5 but both of the operands are integer so answer of this expression in python is 2. To get the 2.5 answer, use floor division.
13). What is the order of precedence in python? i) Parentheses ii) Exponential iii) Multiplication iv) Division v) Addition vi) Subtraction
[A]i,ii,iii,iv,v,vi
[B]ii,i,iii,iv,v,vi
[C]ii,i,iv,iii,v,vi
[D]i,ii,iii,iv,vi,v
Show Answer
Correct Answer: i,ii,iii,iv,v,vi
Notes:
Answer: a
Explanation: For order of precedence, just remember this PEMDAS (similar to BODMAS).
14). What is the answer to this expression, 22 % 3 is?
Show Answer
Correct Answer: 1
Notes:
Answer: b
Explanation: Modulus operator gives the remainder. So, 22%3 gives the remainder, that is, 1.
15). Mathematical operations can be performed on a string.
[A]True
[B]False
[C]False and True
[D]False and True
Show Answer
Correct Answer: False
Notes:
Answer: b
Explanation: You can’t perform mathematical operation on string even if the string is in the form: ‘1234…’.
16). Operators with the same precedence are evaluated in which manner?
[A]Left to Right
[B]Right to Left
[C]Can’t say
[D]None of the mentioned
Show Answer
Correct Answer: Left to Right
Notes:
Answer: a
Explanation: None.
17). What is the output of this expression, 3*1**3?
Show Answer
Correct Answer: 3
Notes:
Answer: c
Explanation: First this expression will solve 1**3 because exponential has higher precedence than multiplication, so 1**3 = 1 and 3*1 = 3. Final answer is 3.
18). Which one of the following has the same precedence level?
[A]Addition and Subtraction
[B]Multiplication, Division and Addition
[C]Multiplication, Division, Addition and Subtraction
[D]Addition and Multiplication
Show Answer
Correct Answer: Addition and Subtraction
Notes:
Answer: a
Explanation: “Addition and Subtraction” are at the same precedence level. Similarly, “Multiplication and Division” are at the same precedence level. However, Multiplication and Division operators are at a higher precedence level than Addition and Subtraction operators.
19). The expression Int(x) implies that the variable x is converted to integer.
[A]True
[B]False
[C]none
[D]none of the mentioned
Show Answer
Correct Answer: True
Notes:
Answer: a
Explanation: Int(x) converts the datatype of the variable to integer and is the example of explicit data conversion.
20). Which one of the following has the highest precedence in the expression?
[A]Exponential
[B]Addition
[C]Multiplication
[D]Parentheses
Show Answer
Correct Answer: Parentheses
Notes:
Answer: d
Explanation: Just remember: PEMDAS, that is, Parenthesis, Exponentiation, Division, Multiplication, Addition, Subtraction. Note that the precedence order of Division and Multiplication is the same. Likewise, the order of Addition and Subtraction is also the same.