What this Python exercise asks you to practise
This scenario tests show basic arithmetic. It belongs to the Expressions and Data Types roadmap and uses the operators · formatting pattern.
Integers, floats, strings, booleans, arithmetic, comparisons, and operator precedence.
Program input
Two integers, one per line.
Input and expected output
A lab assistant needs the four basic results for two readings.
18
4sum=22
difference=14
product=72
quotient=4.50Why: The four operators perform addition, subtraction, multiplication, and division. :.2f formats the quotient to two decimals.
Test how arithmetic behaves when the first reading is below zero.
-9
2sum=-7
difference=-11
product=-18
quotient=-4.50Why: The four operators perform addition, subtraction, multiplication, and division. :.2f formats the quotient to two decimals.
Reference answer with explanation
first = int(input())
second = int(input())
print(f"sum={first + second}")
print(f"difference={first - second}")
print(f"product={first * second}")
print(f"quotient={first / second:.2f}")Read one integer per line, then apply each arithmetic operator to the same two values.
Common beginner check: Forgetting that input() returns text, even when the user types a number.
Open the guided learning workspace
Trace the logic and reveal the line-by-line explanation. The browser compiler unlocks with complete access.
Open problem 4Pattern relevance
This exercise strengthens operators · formatting. Be ready to explain the input, the rule, the boundary cases, and why the chosen approach is appropriate.