Q 1. Which is the correct operator for power(xy)?
A. X^y
B. X**y
C. X^^y
D. None of the mentioned
Show Answer
Answer:-B. X**yExplanation
Explanation:- In python, power operator is x**y i.e. 2**3=8.Q 2. Which one of these is floor division?
A. /
B. //
C. %
D. None of the mentioned
Show Answer
Answer:-B. //Explanation
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.Q 3. 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
Answer:-A. i,ii,iii,iv,v,viExplanation
Explanation:- For order of precedence, just remember this PEMDAS (similar to BODMAS).Q 4. What is the answer to this expression, 22 % 3 is?
A. 7
B. 1
C. 0
D. 5
Show Answer
Answer:-B. 1Explanation
Explanation:- Modulus operator gives the remainder. So, 22%3 gives the remainder, that is, 1.Q 5. Mathematical operations can be performed on a string.
A. True
B. False
Show Answer
Answer:-B. FalseExplanation
Explanation:- You can’t perform mathematical operation on string even if the string is in the form: ‘1234…’.Q 6. 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
Answer:-A. Left to RightQ 7. What is the output of this expression, 3*1**3?
A. 27
B. 9
C. 3
D. 1
Show Answer
Answer:-C. 3Explanation
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.Q 8. 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
Answer:-A. Addition and SubtractionExplanation
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.Q 9. The expression Int(x) implies that the variable x is converted to integer.
A. True
B. False
Show Answer
Answer:-A. TrueExplanation
Explanation:- Int(x) converts the datatype of the variable to integer and is the example of explicit data conversion.Q 10. Which one of the following has the highest precedence in the expression?
A. Exponential
B. Addition
C. Multiplication
D. Parentheses
Leave a Reply