Python Variable Types Explained (Interactive)

1. Integer (Whole Number) Most Used

Used for counting things like age, score, number of items.

age = 30
students = 25
Integers are whole numbers like 1, 20, -5. They do not have decimals.

2. Float (Decimal Number) Most Used

Used for prices, height, weight, percentages.

price = 19.99
height = 1.75
Floats are numbers with decimals like 3.14 or 0.5.

3. String (Text) Most Used

Used for names, messages, cities, anything written.

name = "Khaja"
city = "Birmingham"
Strings are text inside quotes. You can use single or double quotes.

4. Boolean (True/False) Most Used

Used for yes/no decisions.

is_raining = True
is_student = False
Booleans represent True or False only.

5. List (Collection of Items) Most Used

Used to store multiple values.

shopping = ["milk", "bread", "eggs"]
Lists use square brackets and can store many items.

6. Dictionary (Key–Value Pairs) Most Used

Used to store structured information.

person = {
    "name": "Aisha",
    "age": 28,
    "city": "London"
}
Dictionaries store data in key–value pairs like "name": "Aisha".

7. Tuple (Fixed List)

A list that cannot be changed.

colors = ("red", "green", "blue")
Tuples are like lists but cannot be modified after creation.

8. Set (Unique Items)

Stores items with no duplicates.

unique_numbers = {1, 2, 3}
Sets automatically remove duplicates and are unordered.

9. NoneType (No Value)

Represents “nothing” or “empty”.

result = None
None is used when a variable has no value yet.

10. Complex Numbers

Used in scientific and mathematical calculations.

z = 3 + 5j
Complex numbers include a real and imaginary part.

11. Bytes

Used for raw data like files, images, or network data.

data = b"Hello"
Bytes store sequences of numbers between 0–255.

12. Range

Used for loops and sequences of numbers.

numbers = range(5)
Range generates a sequence of numbers, often used in loops.

📘 Multiple Choice Quiz

Choose the correct answer. You get instant feedback!