pyPython Practice LabFrom first print to final round
PYTHON PROBLEM 004 · Starter

Show basic arithmetic

A lab assistant needs the four basic results for two readings.

operators · formattingoperatorsformatting
PROBLEM OVERVIEW

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.

INPUT FORMAT

Program input

Two integers, one per line.

VERIFIED SAMPLE CASES

Input and expected output

Normal case

A lab assistant needs the four basic results for two readings.

Sample input
18
4
Expected output
sum=22
difference=14
product=72
quotient=4.50

Why: The four operators perform addition, subtraction, multiplication, and division. :.2f formats the quotient to two decimals.

Boundary or variation

Test how arithmetic behaves when the first reading is below zero.

Sample input
-9
2
Expected output
sum=-7
difference=-11
product=-18
quotient=-4.50

Why: The four operators perform addition, subtraction, multiplication, and division. :.2f formats the quotient to two decimals.

PYTHON SOLUTION

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.

READY TO PRACTISE?

Open the guided learning workspace

Trace the logic and reveal the line-by-line explanation. The browser compiler unlocks with complete access.

Open problem 4
SKILL TO CARRY FORWARD

Pattern relevance

This exercise strengthens operators · formatting. Be ready to explain the input, the rule, the boundary cases, and why the chosen approach is appropriate.