Beyond Basic Math: Modulo, Floor Division, and Exponents in Python

Опубликовано: 07 Июль 2026
на канале: One Step Clearer
6
0

Want to solve complex math problems in your code? In this video, we dissect three advanced arithmetic operations in Python: Exponentiation, Floor Division, and Modulo.

You'll learn how to calculate powers correctly without using carets, how to divide and round down to the nearest whole number, and how to check if numbers are even or odd using remainders.

📝 CODE WRITTEN IN THIS VIDEO:
--------------------------------------
Exponentiation (Power calculations)
result = 2 ** 3
print(result) # 8

Division comparisons
Normal division returns floats
print(7 / 2) # 3.5
Floor division rounds down to integers
print(7 // 2) # 3

Modulo (Returns division remainder)
print(7 % 2) # 1

Check if a number is even or odd
number = 14
if number % 2 == 0:
print("Even")
else:
print("Odd")


🧠 BONUS CHALLENGES:
--------------------------------------
Test your Python arithmetic logic! Comment your answers below.

Challenge 1:
What is the output of this code?
print(5 ** 2 - 5 // 2)

Options:
A) 23
B) 22.5
C) 20

Challenge 2:
What is the output of this code?
x = 11
y = 4
print(x % y)

Options:
A) 2
B) 3
C) 1

#python #programming #coding #pythontutorial #learnpython #compscience