English

Write a program to enter two integers and perform all arithmetic operations on them. - Computer Science (Python)

Advertisements
Advertisements

Question

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

Answer in Brief
Advertisements

Solution

Program:
#Program to input two numbers and perform all arithmetic operations

#Input the first number
num1 = int(input("Enter first number: "))
#Input the Second number
num2 = int(input("Enter second number: "))

#Printing the result for all arithmetic operations
print("Results:-")
print("Addition: ",num1+num2)
print("Subtraction: ",num1-num2)
print("Multiplication: ",num1*num2)
print("Division: ",num1/num2)
print("Modulus: ", num1%num2)
print("Floor Division: ",num1//num2)
print("Exponentiation: ",num1 ** num2)

OUTPUT:
Enter the first number: 8
Enter the second number: 3
Results:-
Addition:  11
Subtraction:  5
Multiplication:  24
Division:  2.6666666666666665
Modulus:  2
Floor Division:  2
Exponentiation:  512
shaalaa.com
Operators - Arithmetic Operators (-,+,*,/,%)
  Is there an error in this question or solution?
Chapter 5: Getting Started with Python - Exercise [Page 118]

APPEARS IN

NCERT Computer Science [English] Class 11
Chapter 5 Getting Started with Python
Exercise | Q 13. | Page 118
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×