Lesson 4 – Data Types

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.

Main Python Data Types

Example 1: Text (String)

message = "Hello, Python"
print(message)
print(type(message))
        

Output:

Hello, Python
<class 'str'>
        

Example 2: Whole Number (Integer)

count = 25
print(count)
print(type(count))
        

Output:

25
<class 'int'>
        

Example 3: Decimal Number (Float)

price = 3.99
print(price)
print(type(price))
        

Output:

3.99
<class 'float'>
        

Example 4: True/False (Boolean)

is_student = True
print(is_student)
print(type(is_student))
        

Output:

True
<class 'bool'>
        

Example 5: Mixing Data Types

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
        

Why Data Types Matter

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.


Quiz: Test Your Understanding

1. Which data type is used for text?

int
str
float
bool
Correct answer: str

2. Which value is an integer?

4.5
"7"
12
False
Correct answer: 12

3. Which value is a float?

5
5.0
"3.14"
True
Correct answer: 5.0

4. Which value is a boolean?

"True"
1
True
"False"
Correct answer: True

5. What is the type of "Hello"?

int
float
str
bool
Correct answer: str

6. Which of these is a float?

"6"
6
6.2
False
Correct answer: 6.2

7. Which data type stores True or False?

int
bool
str
float
Correct answer: bool

8. What is the type of 3.14?

int
float
str
bool
Correct answer: float

9. Which value is a string?

"Python"
100
4.2
False
Correct answer: "Python"

10. What is the type of the result of 4 + 6?

str
float
int
bool
Correct answer: int
Back to Top