Python Programming
Lesson – Data Types Explained
Prepared by: Kashaf Idrees
BS IT, University of Sargodha
What are Data Types?
Data types are the kind of values a variable can store. Every variable has a data type, so Python
knows how to use it.
1. Integer (int) – Whole Numbers
Examples: 5, 100, -3
```python
age = 18
print(age) # Output: 18
```
Used for whole numbers like age, count, marks.
2. Float (float) – Decimal Numbers
Examples: 3.14, 2.5, -0.99
```python
price = 45.50
print(price) # Output: 45.5
```
Used for money, temperature, or measurements.
3. String (str) – Text
Text must be inside quotes: " " or ' '
Examples: "Kashaf", "BS IT", "Hello World"
```python
name = 'Kashaf'
print(name) # Output: Kashaf
```
Used for names, messages, or any text.
4. Boolean (bool) – True / False
Only two values: True or False
```python
is_student = True
print(is_student) # Output: True
```
Used for conditions and yes/no questions.
Example – All Data Types Together
```python
age = 18 # int
height = 5.5 # float
name = 'Kashaf' # string
is_student = True # boolean
print(age, height, name, is_student)
```
Output:
18 5.5 Kashaf True
Quick Tip to Remember
- Int → Whole number
- Float → Decimal number
- String → Text
- Boolean → True/False