McqMate
These multiple-choice questions (MCQs) are designed to enhance your knowledge and understanding in the following areas: Computer Science Engineering (CSE) , Information Technology Engineering (IT) , Electrical Engineering , Civil Engineering , Mechanical Engineering .
Chapters
1. |
What is the output of print 0.1 + 0.2 == 0.3? |
A. | true |
B. | false |
C. | machine dependent |
D. | error |
Answer» B. false | |
Explanation: neither of 0.1, 0.2 and 0.3 can be represented accurately in binary. the round off errors from 0.1 and 0.2 accumulate and hence there is a difference of 5.5511e-17 between (0.1 + 0.2) and 0.3. |
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 |
Answer» C. k = 2 + 3l | |
Explanation: l (or l) stands for long. |
3. |
What is the type of inf? |
A. | boolean |
B. | integer |
C. | float |
D. | complex |
Answer» C. float | |
Explanation: infinity is a special case of floating point numbers. it can be obtained by float(‘inf’). |
4. |
What does ~4 evaluate to? |
A. | -5 |
B. | -4 |
C. | -3 |
D. | +3 |
Answer» A. -5 | |
Explanation: ~x is equivalent to -(x+1). |
5. |
What is the result of cmp(3, 1)? |
A. | 1 |
B. | 0 |
C. | true |
D. | false |
Answer» A. 1 | |
Explanation: cmp(x, y) returns 1 if x > y, 0 if x == y and -1 if x < y. |
6. |
Which of the following is incorrect? |
A. | float(‘inf’) |
B. | float(‘nan’) |
C. | float(’56’+’78’) |
D. | float(’12+34′) |
Answer» D. float(’12+34′) | |
Explanation: ‘+’ cannot be converted to a float. |
7. |
What is the result of round(0.5) – round(-0.5)? |
A. | 1.0 |
B. | 2.0 |
C. | 0.0 |
D. | value depends on python version |
Answer» D. value depends on python version | |
Explanation: the behavior of the round() |
8. |
What does 3 ^ 4 evaluate to? |
A. | 81 |
B. | 12 |
C. | 0.75 |
D. | 7 |
Answer» D. 7 | |
Explanation: ^ is the binary xor operator. |
Done Studing? Take A Test.
Great job completing your study session! Now it's time to put your knowledge to the test. Challenge yourself, see how much you've learned, and identify areas for improvement. Don’t worry, this is all part of the journey to mastery. Ready for the next step? Take a quiz to solidify what you've just studied.