Python Program To Demonstrate Arithmetic Operators

Write Python code to demonstrate arithmetic operators

# WAP to Demonstrate Arithmetic Operators

a = 12
b = 8
print("\nThe value of num1 is : %d " % a)
print("The value of num2 is : %d \n\n" % b)
print(a, "+", b, "=", a + b)
print(a, "-", b, "=", a - b)
print(a, "*", b, "=", a * b)
print(a, "/", b, "=", a / b)
print(a, "//", b, "=", a // b)
print(b, "Power of", a, "=", a ** b)
print(a, "Mod", b, "=", a % b)

Output:

The value of num1 is : 12 
The value of num2 is : 8 


12 + 8 = 20
12 - 8 = 4
12 * 8 = 96
12 / 8 = 1.5
12 // 8 = 1
8 Power of 12 = 429981696
12 Mod 8 = 4

<< Previous | Next >>


Leave a Reply

Your email address will not be published.