Calculate with variables and turn results into clear output.
A useful program turns stored data into a result.
Python uses familiar operations with programming symbols.
Addition
5 + 2 โ 7
Subtraction
5 - 2 โ 3
Multiplication
5 * 2 โ 10
The operator changes the question Python answers.
Division
17 / 5 โ 3.4
Exact quotient
Floor Division
17 // 5 โ 3
Complete groups
Modulo
17 % 5 โ 2
Remainder
What is printed?
What is printed?
What is printed?
Use ** to raise a number to a power.
2ยณ
In Mathematics
The exponent tells us how many factors of 2 to multiply.
2 ** 3
In Python
Two asterisks write the same power operation.
What value is printed?
Translate each mathematical operation into a Python operator.
Named Value
ฯ becomes the variable pi.
Write Multiplication
Implicit multiplication becomes *.
Write the Power
rยฒ becomes radius ** 2.
Python evaluates grouped and higher-priority operations first.
Press Next to evaluate one rule at a time.
What is printed?
What is printed?
What is printed?
Python evaluates the right side before assigning the result.
What happens when this program runs?
Three small markers turn values into readable text.
Prefix
Place f immediately before the opening quote.
Braces
Put a variable or short expression inside braces.
Surrounding Text
Write labels and punctuation normally inside the string.
f"Total: {total}"
The calculation stays numeric; the f-string handles presentation.
What exact sentence is printed?
Python evaluates a short expression before inserting its result.
Complete it on time and submit it before the deadline.
Key takeaways from this lesson.
Calculate
Use the operator that matches the question you need to answer.
Divide
/ gives a quotient, // gives complete groups, and % gives the remainder.
Order
Parentheses and higher-priority operators are evaluated first.
Format
An f-string embeds values and short expressions inside readable text.
Predict each result before running the code.
1. Predict all six outputs.
2. Run the code and correct any prediction that differs.
3. Label which line demonstrates /, //, %, **, or precedence.
Use complete groups and a remainder to split time.
1. Store 137 in a variable named total_minutes.
2. Calculate complete hours with // and remaining minutes with %.
3. Print both results with one f-string.
2 hours and 17 minutes
Calculate a purchase and report every important value.
1. Calculate the total price in a new variable.
2. Print the item, unit price, quantity, and total on four labeled lines.
3. Use f-strings for every labeled line.
Translate a multi-step formula and report its result.
1. Create variables named wins, draws, and losses. In the formula, w, d, and l represent those values.
2. Translate the formula below into Python and store the result in rating.
3. Print the total number of games and the rating with f-strings.
4. Test with wins = 6, draws = 2, and losses = 2.
Keep calculations numeric and use f-strings for display.
1. Run the program and locate the failing line.
2. Replace both output lines with f-strings.
3. Confirm that the program prints Player: Maya and Total: 30.
4. Add one line that displays the next score after another 5-point bonus.