Write a Python program to create a simple calculator i.e a calculator with addition, subtraction, multiplication, and division functionality using object-oriented programming (OOP).

To create a basic calculator in python we first need to create a class and define different functionalities like addition, subtraction, etc into separate methods.

After that, we will ask the user to choose what functionality they want to execute through an input, then the user will input the required variables and the respective function will be called to compute the result.

Let’s try to implement it in python.


  1. funtions using def in Python
  2. Python’s If and else
  3. While loop in Python

Source Code:


calculator in python

In the above program we have used OOP (i.e class and object) to create a basic python calculator.

Make sure that you typecast the inputs into an integer before using them and also check for invalid inputs prior to calling appropriate methods.

If you have any doubts or suggestions then please comment below.

Leave a Reply

twenty − 15 =