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'>
Mission
0 / 1
Use integer and floating-point variables to produce the output. The expected output is 45.0
.
a = 15
b = 30.0
result = a +
print(result)
Guidelines
AI Tutor
Publish
Design
Upload
Notes
Favorites
Help
Code Editor
Run
Generate
Execution Result