Numbers (int & float)
A free lesson from Swipe Coding · Python, level 2 · updated October 2026
By the Swipe team, founded by Colin · how we make lessons
Python has two main number types you'll use constantly: int for whole numbers (no decimal point) and float for numbers with a decimal point. You never declare which one a variable is — Python decides based on how you write the value.
quantity = 10 # int price = 4.99 # float total = 3.0 # a float, even though it has no fractional part print(type(quantity)) # <class 'int'> print(type(price)) # <class 'float'>
The usual arithmetic operators work as expected: + for addition, - for subtraction, * for multiplication, and / for division. Mixing an int and a float in the same calculation always produces a float, since Python automatically widens the int so no precision is lost.
result = 10 + 3.5 print(result) # 13.5 print(type(result)) # <class 'float'>
There are two special division operators worth knowing: / always produces a float (called true division), even when dividing two ints evenly, while // performs floor division, dropping any remainder to give a whole-number result. The % operator gives you the remainder of a division, which is useful for checking things like whether a number is even.
print(7 / 2) # 3.5 print(7 // 2) # 3 print(7 % 2) # 1
The built-in ____ function lets you check what type a value currently is, such as int or float.
What is the result of 10 + 3.5 in Python, and what type is it?
Writing total = 3.0 creates a float, even though the value has no fractional part.
Variables & Numbers
10 questions · pass with 60% — just like in the app.
What must you write before a variable name when creating it in Python?
Python is dynamically typed, meaning a variable can be reassigned to a value of a different type.
Python's naming convention for variables is ____, e.g. total_score.
Which line creates two variables, a and b, in a single line?
Variable names in Python are case-sensitive, so score and Score are different variables.
The ____ type stores whole numbers with no decimal point.
What type is the value 3.0 in Python?
Adding an int and a float together, like 10 + 3.5, always produces a float.
The built-in ____ function lets you check what type a value currently is.
What does 7 // 2 evaluate to in Python?
Keep your streak going in Swipe Coding
Swipe through every level of Python on your iPhone — with XP, stars, streaks, a personal advisor and the full track beyond these free levels.
Get the Swipe apps →