[ Web Proxy ]
URL:
Viewing: https://www.programminginpython.com/python-program-arithmetic-operations/ [Back]  [Original]

Python program for performing Arithmetic Operations - Programming In Python
Skip to content
Home Python program for performing Arithmetic Operations

Python program for performing Arithmetic Operations

Python program for performing Arithmetic Operations [Python program for performing Arithmetic Operations] Python program for performing Arithmetic Operations

Hello everyone, welcome to Programming In Python. Here in this post I will tell you about a basic Python program for all beginners in Python programming language. It simply takes two integer numbers and performs arithmetic operations like addition, subtraction, multiplication, division, floor division, modulus, and exponential(power) on them. So now let’s do some basic arithmetic operations in Python.

You can also watch the video on YouTube here.

Program on GitHub

Arithmetic Operations Code Visualization

Task :

To perform arithmetic operations on two integers.

Approach :

  • Read twoinput integers using input() or raw_input().
  • Addition operation using + operator,num1 + num2 adds 2 numbers.
  • Subtractionoperation using - operator,num1 - num2 right hand operand from left hand operand.
  • Multiplicationoperation using * operator,num1 * num2 multiplies 2 numbers.
  • Divisionoperation using / operator,num1 / num2divides left hand operand by right hand operand.
  • Floor Division operation using // operator, num1 // num2divides left hand operand by right hand operand, here it removes the values after decimal point.
  • Modulus % operator when applied returns the remainder when left hand operand is divided by right hand operand num1 % num2.
  • Exponential operation using ** operator,num1 ** num2returns value of num1 num2
  • Print the result of each operation.

Program on GitHub

Program :

num1 = int(input('Enter First number: '))
num2 = int(input('Enter Second number '))

add = num1 + num2
dif = num1 - num2
mul = num1 * num2
div = num1 / num2
floor_div = num1 // num2
power = num1 ** num2
modulus = num1 % num2

print('Sum of ',num1 ,'and' ,num2 ,'is :',add)
print('Difference of ',num1 ,'and' ,num2 ,'is :',dif)
print('Product of' ,num1 ,'and' ,num2 ,'is :',mul)
print('Division of ',num1 ,'and' ,num2 ,'is :',div)
print('Floor Division of ',num1 ,'and' ,num2 ,'is :',floor_div)
print('Exponent of ',num1 ,'and' ,num2 ,'is :',power)
print('Modulus of ',num1 ,'and' ,num2 ,'is :',modulus)

Output :

Arithmetic Operations in Python [Arithmetic Operations in Python]Arithmetic Operations in Python

Program on GitHub

Course Suggestion

Want to be strong at OOP in Python? If yes, I would suggest you take the course below.
Course:
Object Oriented Programming in Python

 

Online Python Compiler

Tagged: basic math numbers

Post navigation

2 thoughts on “Python program for performing Arithmetic Operations

  1. svg%3E [svg%3E] Rejekibet Apk says:

    Great post! I found the examples of arithmetic operations in Python really helpful. It’s nice to see clear explanations alongside the code. Looking forward to more programming tips!

  2. Great post! I really appreciate the clear examples of arithmetic operations in Python. They make it easy to follow along and understand how to implement these concepts in my own projects. Thanks for sharing!

Leave a Reply Cancel reply

author:
email:
url:
comment:
ak_hp_textarea:

Programming In Python 2026. Powered By BlazeThemes.

Web Proxy Viewer  |  New URL  |  Original Page