Lesson 3 of 16
Lesson Progress: 0%
Code Example
# Add (+)
print(5 + 2)
print(10 + 3)
# Subtract (-)
print(8 - 3)
print(10 - 4)
# Multiply (*)
print(4 * 2)
print(3 * 3)
# Divide (/)
print(8 / 2)
print(10 / 5)Instructions
▲ ← Click the triangle to hide or reveal instructions.Python Code Editor
Task Incomplete
Editor Input:
Editor Output:
+ means add.- means subtract.* means multiply./ means divide.print() to show the answer on the screen.print(5 + 2) adds 5 and 2 and shows the answer.print(8 - 3) takes 3 away from 8.print(4 * 2) multiplies 4 and 2.print(8 / 2) divides 8 by 2.Code Example
print(10 % 3)
print(8 % 4)
print(7 % 5)Instructions
▲ ← Click the triangle to hide or reveal instructions.Python Code Editor
Task Incomplete
Editor Input:
Editor Output:
% symbol in Python is like a "leftovers" counter for math problems.10 % 3, Python sees that 3 fits into 10 three times, with 1 left over, so the answer is 1.8 % 4, Python will give you a 0.Code Example
number = 7
print(number % 2)
print(number % 2 == 0)
print(number % 2 == 1)
number = 10
print(number % 2)
print(number % 2 == 0)
print(number % 2 == 1)Instructions
▲ ← Click the triangle to hide or reveal instructions.Python Code Editor
Task Incomplete
Editor Input:
Editor Output:
% 2 trick to find out if a number is even or odd.number % 2 will be 0.number % 2 will be 1.== 0 to ask Python: "Is this number even?"== 1 to ask Python: "Is this number odd?"True or False on the screen.