Our Features

Our Features
.

Sunday, 5 June 2016

Numeric Types

This set of Python Multiple Choice Questions & Answers (MCQs) focuses on “Numeric Types”.
1. What is the output of print 0.1 + 0.2 == 0.3?
a) True
b) False
c) Machine dependent
d) Error
View Answer
2. Which of the following is not a complex number?
a) k = 2 + 3j
b) k = complex(2, 3)
c) k = 2 + 3l
d) k = 2 + 3J
View Answer
3. What is the type of inf?
a) Boolean
b) Integer
c) Float
d) Complex
View Answer

4. What does ~4 evaluate to?
a) -5
b) -4
c) -3
d) +3
View Answer
5. What does ~~~~~~5 evaluate to?
a) +5
b) -11
c) +11
d) -5
View Answer
Answer: a
Explanation: ~x is equivalent to -(x+1).

6. Which of the following is incorrect?
a) x = 0b101
b) x = 0x4f5
c) x = 19023
d) x = 03964
View Answer

Answer: d
Explanation: Numbers starting with a 0 are octal numbers but 9 isn’t allowed in octal numbers.
7. What is the result of cmp(3, 1)?
a) 1
b) 0
c) True
d) False
View AnswerAnswer: a
Explanation: cmp(x, y) returns 1 if x > y, 0 if x == y and -1 if x < y.[/expand]


No comments:

Post a Comment