Python MCQs on Data Type: SET 2

11. Which of the following results in a SyntaxError?

a) ‘”Once upon a time…”, she said.’

b) “He said, ‘Yes!’”

c) ‘3\’

d) ”’That’s okay”’

Check Answer
Answer: c
Explanation: Carefully look at the colons.


12. The following is displayed by a print function call. Select all of the function calls that result in this output.




b) print(”’tomdickharry”’)

c) print(‘tom\ndick\nharry’)


Check Answer
Answer: c
Explanation: The \n adds a new line.


13. What is the average value of the following Python code snippet?

>>>grade1 = 80

>>>grade2 = 90

>>>average = (grade1 + grade2) / 2

a) 85.0

b) 85.1

c) 95.0

d) 95.1

Check Answer

Answer: a
Explanation: Cause a decimal value of 0 to appear as output.


14. Select all options that print.


a) print(‘hello’, ‘how’, ‘are’, ‘you’)

b) print(‘hello’, ‘how’, ‘are’, ‘you’ + ‘-‘ * 4)

c) print(‘hello-‘ + ‘how-are-you’)

d) print(‘hello’ + ‘-‘ + ‘how’ + ‘-‘ + ‘are’ + ‘you’)

Check Answer

Answer: c
Explanation: Execute in the shell.


15. What is the return value of trunc()?

a) int

b) bool

c) float

d) None

Check Answer
Answer: a
Explanation: Execute help(math.trunc) to get details.


16. What is the output of print 0.1 + 0.2 == 0.3?

a) True

b) False

c) Machine dependent

d) Error

Check Answer

Answer: b
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.


17. 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

Check Answer

Answer: c
Explanation: l (or L) stands for long.


18. What is the type of inf?

a) Boolean

b) Integer

c) Float

d) Complex

Check Answer

Answer: c
Explanation: Infinity is a special case of floating point numbers. It can be obtained by float(‘inf’).


19. What does ~4 evaluate to?

a) -5

b) -4

c) -3

d) +3

Check Answer
Answer: a
Explanation: ~x is equivalent to -(x+1).


20. What does ~~~~~~5 evaluate to?

a) +5

b) -11

c) +11

d) -5

Check Answer
Answer: a
Explanation: ~x is equivalent to -(x+1).

Page  1  2  3

Python Interview Questions (MCQs)

We have divided these Python Questions and Answers into various parts based on the topics. Open the Topic of your choice and Practice these MCQs.

Python MCQs on Variables and Operators Python MCQs on Precedence and Associativity
Python MCQs on Data Type Python MCQs on Boolean
Python MCQs on Bitwise Operators Python MCQs on Formatting and Advance Formatting
Python MCQs on Decorators Python MCQs on While and For Loops
Python MCQs on List Python MCQs on List Comprehension
Python MCQs on String Python MCQs on Tuple
Python MCQs on SET Python MCQs on Dictionary
Python MCQs on Functions Python MCQs on Argument Parsing
Python MCQs on Global and Local Variables Python MCQs on Recursion
Python MCQs on Mapping Functions Python MCQs on Modules
Python MCQs on Regular Expressions Python MCQs on Files
Python MCQs on Overloading Python MCQs on Classes and Objects
Python MCQs on Inheritance Python MCQs on Polymorphism and Encapsulation
Python MCQs on Exception Handling


Leave a Comment