Print a small report about two numbers.
What to build
A report that combines text, calculations, a blank line and a chosen separator. The lines that read the numbers are written for you.
Requirements
- On the first line, print the sum in the form
A + B = S. - On the second line, print the product in the form
A x B = P. - Print a blank line.
- On the last line, print A, B, the sum and the product, separated by
,with no spaces.
Input
Two lines, each with one whole number.
Output
Four lines, as in the example. The third is empty.
Constraints
Each number is from -1000 to 1000.
Example
Input:
3
4
Output:
3 + 4 = 7
3 x 4 = 12
3,4,7,12
Why it works
Without quotes, Python works out a + b first and prints the result. With sep=",", the same four values are printed in one neat row.
Examples
Example 1 · Input
3 4
Expected output
3 + 4 = 7 3 x 4 = 12 3,4,7,12
Example 2 · Input
10 -2
Expected output
10 + -2 = 8 10 x -2 = -20 10,-2,8,-20
Prompts inside input() are ignored when checking, so input("n: ") is fine.
Hints
Hint 1
A calculation can go straight inside print: print(a + b).
Hint 2
print() on its own makes the blank line.
Hint 3
Mix text and values: print(a, "+", b, "=", a + b).
Solution
Show one correct solution (try it yourself first)
a = int(input()) b = int(input()) print(a, "+", b, "=", a + b) print(a, "x", b, "=", a * b) print() print(a, b, a + b, a * b, sep=",")