Computer Science Researcher • Educator • Programming Instructor
Every value in Python has a specific data type. Understanding these types helps you decide how to store information such as text, numbers, calculations, and True/False conditions. This lesson explains the four most common data types used by beginners.
message = "Hello, Python"
print(message)
print(type(message))
Output:
Hello, Python
<class 'str'>
count = 25
print(count)
print(type(count))
Output:
25
<class 'int'>
price = 3.99
print(price)
print(type(price))
Output:
3.99
<class 'float'>
is_student = True
print(is_student)
print(type(is_student))
Output:
True
<class 'bool'>
name = "Ali"
age = 16
print("Student name is", name)
print("Age next year will be", age + 1)
Output:
Student name is Ali
Age next year will be 17
Data types decide what actions Python can perform. For example, you can add two numbers together, but you cannot add a number to a word. Understanding data types helps you avoid errors and write more powerful programs.
1. Which data type is used for text?
int2. Which value is an integer?
4.53. Which value is a float?
54. Which value is a boolean?
"True"5. What is the type of "Hello"?
int6. Which of these is a float?
"6"7. Which data type stores True or False?
int8. What is the type of 3.14?
int9. Which value is a string?
"Python"10. What is the type of the result of 4 + 6?
str