Python Data Types and Operators: 50 Challenging MCQs
Questions
1. Which of the following is **immutable** in Python?
a) List
b) Set
c) Dictionary
d) Tuple
2. What is the output of the following code?
```python
x=5/2
print(type(x))
```
a) <class 'int'>
b) <class 'float'>
c) <class 'complex'>
d) <class 'decimal'>
3. What is the difference between a list and a tuple?
a) Lists are mutable; tuples are immutable.
b) Lists are immutable; tuples are mutable.
c) Lists and tuples are both immutable.
d) Lists and tuples are both mutable.
4. Which Python operator is used to check **membership**?
a) in
Python Data Types and Operators: 50 Challenging MCQs
b) ==
c) is
d) not
5. What does the `is` operator compare?
a) Values
b) Memory locations
c) Data types
d) Variable names
6. What is the result of `2 ** 3 ** 2`?
a) 64
b) 512
c) 729
d) 8
7. Which of the following is a **frozenset**?
a) A mutable set
b) An immutable set
c) A subset
d) None of these
8. How can you convert a list `[1, 2, 3]` to a tuple?
a) tuple([1, 2, 3])
b) list((1, 2, 3))
c) set([1, 2, 3])
Python Data Types and Operators: 50 Challenging MCQs
d) None of the above
9. What is the output of this expression: `10 + 4 * 3 - 6 / 2`?
a) 24
b) 18
c) 20
d) 22
10. What is the result of the following code?
```python
x = 10
y = 10
print(x is y)
```
a) True
b) False
c) Error
d) None
... (Questions 11 to 50 follow in a similar format) ...
Python Data Types and Operators: 50 Challenging MCQs
Answers
1. d) Tuple
2. b) <class 'float'>
3. a) Lists are mutable; tuples are immutable.
4. a) in
5. b) Memory locations
6. b) 512
7. b) An immutable set
8. a) tuple([1, 2, 3])
9. c) 20
10. a) True
... (Answers 11 to 50 correspond to their respective questions above) ...