Skip to main content
Crowdfunding
Python + AI for Geeks
Practice

Working with Numbers in Python

In Python, there are two primary data types for handling numerical data: integers (int) and floating-point numbers (float).


Integer Type

Integers are numbers without decimal points, such as -2, 0, 10.

In Python, integers are represented as int.

Integer Example
age = 25

initial_value = 0

print(type(age)) # <class 'int'>

Floating-Point Type

Floating-point numbers are numbers with decimal points, like 3.14, -2.1.

In Python, float data types are represented as float.

Float Example
temperature = 36.5

price = 19.99

print(type(temperature)) # <class 'float'>

When you add an integer and a float, the result is returned as a float.

Adding Integer and Float
result = 10 + 3.5

print(result) # 13.5
print(type(result)) # <class 'float'>

Want to learn more?

Join CodeFriends Plus membership or enroll in a course to start your journey.