Aral Code

Variables & Data Lesson 6 of 23

Python Data Types

The main Python data types — str, int, float, bool, None, list, tuple, dict and set — how to check them with type(), and how to convert between them.

Every value in Python has a type that decides what you can do with it. You can multiply numbers but not names; you can make text uppercase but not a price. Knowing the types helps you avoid errors.

The built-in types

TypeNameExample
strString (text)"Mabini", 'Grade 9'
intInteger (whole number)15, -3, 2026
floatDecimal number89.5, 0.12
boolBooleanTrue, False
NoneTypeNothingNone
listOrdered, changeable list["Math", "Science"]
tupleOrdered, unchangeable list(14.6, 121.0)
dictKey–value pairs{"name": "Ana", "age": 15}
setUnordered, no duplicates{"red", "blue"}

Checking a type with type()

print(type("Hello"))
print(type(42))
print(type(3.14))
print(type(True))
print(type(None))
print(type([1, 2, 3]))

Output

<class 'str'>
<class 'int'>
<class 'float'>
<class 'bool'>
<class 'NoneType'>
<class 'list'>

int and float

Python keeps whole numbers and decimals as separate types. Dividing with / always gives a float, even when the answer is whole:

print(10 / 2)
print(10 // 3)    # whole-number division
print(7 + 2.0)    # int + float gives float

Output

5.0
3
9.0

Python's integers have no size limit. 2 ** 100 works perfectly, which is great for math problems.

bool

Booleans are written with a capital letter: True and False. Comparisons produce booleans:

grade = 82
passed = grade >= 75
print(passed)

Output

True

None

None means "no value". It's like JavaScript's null. For example, a winner before the contest is decided:

winner = None
if winner is None:
    print("Wala pang nanalo.")

Output

Wala pang nanalo.

Converting between types

FunctionExampleResult
int()int("25"), int(9.8)25, 9 (cuts off decimals)
float()float("12.5"), float(3)12.5, 3.0
str()str(100)"100"
bool()bool(0), bool("hi")False, True
age = 15
message = "I am " + str(age) + " years old."
print(message)

Output

I am 15 years old.

Without str(), joining text and a number gives a TypeError. (An f-string, f"I am {age} years old.", avoids the problem completely.)

Truthy and falsy

When used as a condition, these values count as False: 0, 0.0, "" (empty string), [], {}, None and False. Everything else counts as True. This allows short checks:

name = input("Name: ")
if not name:
    print("You didn't type anything!")

Dynamic typing

A Python variable can point to a value of any type, and can change later. x = 5 then x = "five" is allowed. This makes Python quick to write, but it's your job to keep track of what's inside each variable.

Quick Quiz

Check what you learned. Walang grade ito, practice lang. 🙂

1. What is the type of 7.0?
2. What does 10 / 5 give in Python?
3. Which is the correct Python boolean?
4. What does int(9.99) return?

By Sir Reyel · Last updated 2026-12-04