Built-in types and conversion
Python programs work by moving values around, comparing them, and transforming them into new forms. To do that reliably, Python needs to know what kind of value it is dealing with at any moment. This lesson exists to orient us to Python’s most common built-in data types and to show how values can be converted when a different form is required.
Understanding these basics makes later work—calculations, decisions, file handling, and AI-related processing—feel predictable rather than mysterious.
Common built-in data types
Python includes a small set of built-in data types that appear constantly in real programs. Three of the most common are integers, floating-point numbers, and booleans.
An int represents a whole number. A float represents a number with a decimal point. A bool represents a truth value.
count = 8 # int
distance = 42.5 # float
visible = True # bool
These types exist to reflect different kinds of real-world values. Counts, measurements, and yes-or-no conditions are not interchangeable, and Python keeps them distinct on purpose.
How Python represents values
Every value in Python has an associated type that tells Python how to store it and how to operate on it. That type influences what calculations make sense and how expressions behave.
For example, adding two integers produces an integer, while involving a floating-point value produces a floating-point result.
total = 3 + 4
average = 3 + 4.0
The values look similar, but Python treats them differently because their types differ.
Checking a value’s type
Sometimes it is useful to confirm what type a value has at runtime. Python provides a built-in function for this purpose.
radius = 1737
print(type(radius))
This produces information about the value’s type rather than its contents. It is a simple way to verify assumptions while exploring or experimenting.
Converting between basic types
Python allows values to be converted from one basic type to another using built-in conversion functions. These conversions are explicit and intentional.
moons = "79"
count = int(moons)
Here, a string containing digits is converted into an integer so it can participate in numeric calculations.
Conversions also work between numeric types.
diameter = 12742
diameter_km = float(diameter)
These conversions create new values rather than changing the original ones.
How conversion affects behavior
Type conversion directly affects how a program behaves. Numeric operations, comparisons, and output formatting all depend on the types involved.
pages = 3
total = pages * 2
If pages were a floating-point value, the result would also be floating-point. If it were a boolean, the expression would mean something else entirely.
Being aware of types and conversions helps keep program behavior aligned with intent, especially as programs grow beyond simple scripts.
Conclusion
We now know how Python represents basic kinds of values, how to identify their types, and how to convert between them when needed. This is enough to recognize what Python is doing when numbers and truth values interact in real programs.
With this orientation in place, we are ready to work more confidently with expressions and output in the next lessons.