Skip to content
Exercises · Q13

Q.Write a program to enter two integers and perform all arithmetic operations on them.

West Bengal WbchseTextbookSubjective· 3mImportance★★★★★est
82% · 40/49 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

Take two integers and print the result of every arithmetic operator (+, −, *, /, //, %, **) — for 10 and 3 the results are 13, 7, 30, 3.33…, 3, 1 and 1000.

The point of this exercise is to see all of Python's arithmetic operators side by side, especially the three division-family operators that beginners confuse: / (true division, always float), // (floor division) and % (remainder).

# All arithmetic operations on two integers
num1 = int(input("Enter first integer: "))
num2 = int(input("Enter second integer: "))

print("Sum =", num1 + num2)
print("Difference =", num1 - num2)
print("Product =", num1 * num2)
print("Division =", num1 / num2)
print("Floor Division =", num1 // num2)
print("Modulus =", num1 % num2)
print("Exponent =", num1 ** num2)

Sample run with num1 = 10, num2 = 3:

Enter first integer: 10
Enter second integer: 3
Sum = 13
Difference = 7
Product = 30
Division = 3.3333333333333335
Floor Division = 3
Modulus = 1
Exponent = 1000
``` …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.