Welcome to this quiz on Python Variables and Data Types!
Variables and data types are fundamental concepts in Python programming. Variables store different types of values, such as numbers, text, or collections. Python provides various built-in data types, including integers, floats, strings, lists, tuples, dictionaries, and more. Understanding these concepts is essential for writing efficient and error-free Python programs.
This quiz contains 20 questions to test your knowledge, including multiple-choice, true/false, and fill-in-the-blank questions. Let’s see how well you know Python’s variables and data types!
Table of Contents:
- Python quizzes for beginners series
Variables and Data Types Quiz
Multiple Choice Questions (MCQs)
1. What is the correct way to declare a variable in Python?
a) int x = 5
b) x = 5
c) declare x = 5
d) var x = 5
Answer
b) x = 5
2. Which of the following is NOT a valid variable name in Python?
a) my_var
b) _value
c) 2nd_var
d) VarName
Answer
c) 2nd_var
(Variable names cannot start with a number)
3. What data type is the result of type(5.0)
in Python?
a) int
b) float
c) double
d) str
Answer
b) float
4. Which of the following is an immutable data type in Python?
a) list
b) tuple
c) dict
d) set
Answer
b) tuple
5. What will print(type("Hello"))
output?
a)
b)
c)
d)
Answer
b)
6. Which of the following is NOT a built-in data type in Python?
a) int
b) float
c) char
d) bool
Answer
c) char
(Python uses str
for characters)
7. What is the output of bool(0)
?
a) True
b) False
c) 0
d) None
Answer
b) False
8. What is the result of 5 // 2
in Python?
a) 2.5
b) 2
c) 2.0
d) 3
Answer
b) 2
(Floor division removes the decimal part)
9. What function is used to get user input in Python?
a) input()
b) scanf()
c) read()
d) get()
Answer
a) input()
10. What will x = "10"; print(type(x))
output?
a)
b)
c)
d)
Answer
b)
True/False Questions
11. Python variables are dynamically typed, meaning you don’t need to declare their type explicitly.
Answer
True
12. Strings in Python are mutable.
Answer
False (Strings are immutable)
13. The None
keyword represents the absence of a value in Python.
Answer
True
14. The isinstance(5.0, int)
function will return True
.
Answer
False (5.0 is a float)
15. tuple
and list
are the same, except that tuples are immutable.
Answer
True
Fill in the Blanks
16. The keyword used to define a variable in Python is ______
.
Answer
There is no keyword, you just assign a value (e.g., x = 10
).
17. A dictionary in Python stores data in ______
pairs.
Answer
Key-value
18. The data type of True
and False
is ______
.
Answer
Boolean (bool
)
19. To convert an integer 10
to a string, we use ______
.
Answer
str(10)
20. The built-in function to check the data type of a variable is ______
.
Answer
type()
How did you do? 🎯
- 18-20 correct → 🏆 Excellent! You’re a Python functions pro!
- 14-17 correct → 👍 Great job! Keep practicing.
- 10-13 correct → 🙂 Good, but there’s room for improvement.
- Below 10 → 🤔 No worries! Review the concepts and try again.
#Python #Variables #Data #Types #Quiz