Python Programming MCQ - Data Types
11. What will be the output of the following code?
arr = [1,2,3,4,5,6]
print(a[::2])
A. [1,3,5]
B. [2,4,6]
C. [1,2]
D. [5,6]
View Answer
Ans : A
Explanation: This will print the every second element from starting. So, Option A is correct.
12. Which of these is not a core data type?
A. List
B. Tuple
C. Dictionary
D. Class
View Answer
Ans : D
Explanation: Class is a user defined data type So, Option D is correct.
13. Which of these about a dictionary is false?
A. The values of a dictionary can be accessed using keys
B. The keys of a dictionary can be accessed using values
C. Dictionaries aren’t ordered
D. Dictionaries are mutable
View Answer
Ans : B
Explanation: The values of a dictionary can be accessed using keys but vice versa is not true. So, Option B is correct.
14. Which of the following is incorrect about dictionary keys?
A. More than one key isn’t allowed
B. When duplicate keys encountered, the last assignment wins
C. Keys must be immutable
D. Keys must be integers
View Answer
Ans : D
Explanation: Keys can be of any data type which is immutable. So, Option D is correct.
15. Which of the follwing are the keys in the given statement : abc = {"first":10, "second":20}
A. 10, 20
B. first, second
C. first, 10, second, 20
D. first, 20
View Answer
Ans : A
Explanation: 10,20 are the keys in the given statement. So, Option A is correct.
16. Which of the following data type is used to store values in Key & Value format?
A. List
B. Tuple
C. Dictionary
D. Set
View Answer
Ans : C
Explanation: Dictionary store values in key value format. So, Option C is correct.
17. What is the output of following: set([1,1,2,3,4,2,3,4])
A. [1,1,2,3,4,2,3,4]
B. {1,2,3,4}
C. {1,1,2,3,4,2,3,4}
D. Invalid Syntax
View Answer
Ans : B
Explanation: Set will remove the duplicate values from the list. So, Option B is correct.
18. Which of the following statements is used to create an empty set?
A. []
B. {}
C. ()
D. set()
View Answer
Ans : D
Explanation: set() is used to create an empty set . So, Option D is correct.
19. Which one of the following is False regarding data types in Python?
A. In python, explicit data type conversion is possible
B. Mutable data types are those that can be changed.
C. Immutable data types are those that cannot be changed.
D. None of the above
View Answer
Ans : D
Explanation: None of the above is False regarding data types in Python.
20. Which of the following function is used to know the data type of a variable in Python?
A. datatype()
B. typeof()
C. type()
D. vartype()
View Answer
Ans : C
Explanation: type() function is used to know the data type of a variable in Python. So,option C is correct.
Also check :
Discussion