• Python Reference

• Other Reference

# Python Programming Multiple Choice Question - Data Types

This section focuses on the "Data Types" of the Python programming. These Multiple Choice Questions (mcq) should be practiced to improve the Python programming skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.

1. Which statement is correct?

A. List is immutable && Tuple is mutable
B. List is mutable && Tuple is immutable
C. Both are Mutable.
D. Both are Immutable

2. Suppose a list with name arr, contains 5 elements. You can get the 2nd element from the list using:

A. arr[-2]
B. arr
C. arr[-1]
D. arr

3. How to get last element of list in python? Suppose we have list with name arr, contains 5 elements.

A. arr
B. arr
C. arr[last]
D. arr[-1]

4. How to copy one list to another in python?

A. l1[] = l2[]
B. l1[] = l2
C. l1[] = l2[:]
D. l1 = l2

5. Suppose a tuple arr contains 10 elements. How can you set the 5th element of the tuple to 'Hello'?

A. arr = 'Hello'
B. arr(4) = 'Hello'
C. arr = 'Hello'
D. Elements of tuple cannot be changed

6. What type of data is: arr = [(1,1),(2,2),(3,3)]?

A. Array of tuples
B. Tuples of lists
C. List of tuples
D. Invalid type

7. Can tuple be used as dictionary key in python?

A. True
B. False
C. Tuple is not used in python
D. None of the above

8. What is the output of the following program : print((1, 2) + (3, 4))

A. (1, 2), (3, 4)
B. (4, 6)
C. (1, 2, 3, 4)
D. Invalid Syntax

9. 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]

10. Which of these is not a core data type?

A. List
B. Tuple
C. Dictionary
D. Class

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

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

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

14. Which of the following data type is used to store values in Key & Value format?

A. List
B. Tuple
C. Dictionary
D. Set

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

16. Which of the following statements is used to create an empty set?

A. []
B. {}
C. ()
D. set()

17. Which one of the following is mutable data type?

A. set
B. int
C. str
D. tupl

18. Which one of the following is immutable data type?

A. list
B. set
C. int
D. dict

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

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()

Also check :

Discussion