Understanding Python Data Types - 25 Multiple Choice Questions
1. What is the output of `type(5)` in Python?
A) int
B) float
C) str
D) None
Answer: A
A) int
B) float
C) str
D) None
Answer: A
2. Which of the following is not a built-in data type in Python?
A) List
B) Dictionary
C) Set
D) Character
Answer: D
A) List
B) Dictionary
C) Set
D) Character
Answer: D
3. How do you create a list in Python?
A) `list = (1, 2, 3)`
B) `list = [1, 2, 3]`
C) `list = {1, 2, 3}`
D) `list = <1, 2, 3>`
Answer: B
A) `list = (1, 2, 3)`
B) `list = [1, 2, 3]`
C) `list = {1, 2, 3}`
D) `list = <1, 2, 3>`
Answer: B
4. What type of data structure is a dictionary?
A) Ordered collection of elements
B) Unordered collection of key-value pairs
C) Immutable sequence of elements
D) None of the above
Answer: B
A) Ordered collection of elements
B) Unordered collection of key-value pairs
C) Immutable sequence of elements
D) None of the above
Answer: B
5. Which of the following is used to define a tuple?
A) `[1, 2, 3]`
B) `(1, 2, 3)`
C) `{1, 2, 3}`
D) `<1, 2, 3>`
Answer: B
A) `[1, 2, 3]`
B) `(1, 2, 3)`
C) `{1, 2, 3}`
D) `<1, 2, 3>`
Answer: B
6. What will `len("Hello")` return?
A) 5
B) 4
C) 6
D) None of the above
Answer: A
A) 5
B) 4
C) 6
D) None of the above
Answer: A
7. Which data type is used to represent True and False values?
A) int
B) bool
C) str
D) None of the above
Answer: B
A) int
B) bool
C) str
D) None of the above
Answer: B
8. How do you create a set in Python?
A) `set = [1, 2, 3]`
B) `set = {1, 2, 3}`
C) `set = (1, 2, 3)`
D) `set = <1, 2, 3>`
Answer: B
A) `set = [1, 2, 3]`
B) `set = {1, 2, 3}`
C) `set = (1, 2, 3)`
D) `set = <1, 2, 3>`
Answer: B
9. What is the result of `3 + 4.5`?
A) 7
B) 7.5
C) 34.5
D) None of the above
Answer: B
A) 7
B) 7.5
C) 34.5
D) None of the above
Answer: B
10. Which of the following is mutable?
A) Tuple
B) String
C) List
D) None of the above
Answer: C
A) Tuple
B) String
C) List
D) None of the above
Answer: C
11. How do you access the first element of a list named `my_list`?
A) `my_list[0]`
B) `my_list(0)`
C) `my_list{0}`
D) `my_list[1]`
Answer: A
A) `my_list[0]`
B) `my_list(0)`
C) `my_list{0}`
D) `my_list[1]`
Answer: A
12. What does the `isinstance()` function do?
A) Checks the type of a variable
B) Checks if two variables are equal
C) Converts a variable to a specified type
D) None of the above
Answer: A
A) Checks the type of a variable
B) Checks if two variables are equal
C) Converts a variable to a specified type
D) None of the above
Answer: A
13. Which data type can store multiple values?
A) int
B) bool
C) list
D) None of the above
Answer: C
A) int
B) bool
C) list
D) None of the above
Answer: C
14. What is the output of `str(100)`?
A) 100
B) "100"
C) '100'
D) None of the above
Answer: B
A) 100
B) "100"
C) '100'
D) None of the above
Answer: B
15. How do you convert a list to a set?
A) `set(my_list)`
B) `list(my_set)`
C) `my_list.to_set()`
D) None of the above
Answer: A
A) `set(my_list)`
B) `list(my_set)`
C) `my_list.to_set()`
D) None of the above
Answer: A
16. Which operator is used to check the type of a variable?
A) `type()`
B) `isinstance()`
C) `checktype()`
D) None of the above
Answer: A
A) `type()`
B) `isinstance()`
C) `checktype()`
D) None of the above
Answer: A
17. What will `[]` return?
A) An empty string
B) An empty list
C) An empty tuple
D) None of the above
Answer: B
A) An empty string
B) An empty list
C) An empty tuple
D) None of the above
Answer: B
18. Which of the following can be a key in a dictionary?
A) List
B) Tuple
C) Set
D) None of the above
Answer: B
A) List
B) Tuple
C) Set
D) None of the above
Answer: B
19. What is the result of `1 < 2 < 3`?
A) True
B) False
C) 1
D) None of the above
Answer: A
A) True
B) False
C) 1
D) None of the above
Answer: A
20. Which of the following will create a string?
A) `str(100)`
B) `100 + "200"`
C) `100 + 200`
D) None of the above
Answer: A
A) `str(100)`
B) `100 + "200"`
C) `100 + 200`
D) None of the above
Answer: A
21. How do you create a dictionary in Python?
A) `dict = {}`
B) `dict = []`
C) `dict = ()`
D) `dict = <>`
Answer: A
A) `dict = {}`
B) `dict = []`
C) `dict = ()`
D) `dict = <>`
Answer: A
22. Which function is used to read input from the user?
A) `input()`
B) `getinput()`
C) `read()`
D) None of the above
Answer: A
A) `input()`
B) `getinput()`
C) `read()`
D) None of the above
Answer: A
23. What will `bool(0)` return?
A) True
B) False
C) None
D) 0
Answer: B
A) True
B) False
C) None
D) 0
Answer: B
24. What does the `del` statement do?
A) Deletes a variable
B) Deletes a list
C) Deletes an item from a dictionary
D) All of the above
Answer: D
A) Deletes a variable
B) Deletes a list
C) Deletes an item from a dictionary
D) All of the above
Answer: D
25. What is the result of `{"a": 1, "b": 2}["a"]`?
A) 1
B) "a"
C) 2
D) None of the above
Answer: A
A) 1
B) "a"
C) 2
D) None of the above
Answer: A
0 Comments