Python MCQ and Answers – Data types
This collection of Python Multiple Choice Questions and Answers (MCQs): Quizzes & Practice Tests with Answer focuses on “Data types”.
1. What is the data type of print(type(5))
?
A double
B float
C integer
D int
2. Which of the following is not a built-in data type?
A Dictionary
B Lists
C Tuples
D Class
3. Which of the following statement is correct?
A List and Tuple are Immutable
B List and Tuple are Mutable
C Tuple is immutable and List is mutable
D Tuple is mutable and List is immutable
4. What is the output of the following code?
str = "welcome" print(str[:2])
A el
B we
C lc
D wel
5. What is the return type of id() function?
A bool
B list
C int
D double
6. What is the data type of print(type(0xEE))
?
A int
B hex
C hexint
D number
7. What is the output of the following code: print(type({}) is set)
?
A True
B False
8. In Python 3, what is the type of type(range(10))
?
A tuple
B int
C range
D list
9. What type of error can arises when you execute the following code x = y
?
A TypeError
B ValueError
C NameError
D SyntaxError
10. What is the output of the following code?
def test(n): n = n + '3' n = n * 3 return n print(test("hello"))
A hello3hello3hello3
B IndentationError
C hello3
D None of the mentioned
11. Suppose we have a list with 6 elements. You can get the second element from the list using ________
A mylist[-2]
B mylist[2]
C mylist[-1]
D mylist[1]
12. What is the data type of the following object?
x = [5, 22, 'str', 1]
A tuple
B array
C dictionary
D list
13. To store values as regards key and value we use ___________.
A tuple
B class
C dictionary
D list
14. Can we use tuple as dictionary key?
A True
B False
15. What is the return value of trunc() function?
A bool
B int
C float
D None