How to create a simple calculator in python

Create your own Calculator

Create your own Calculator in Pycharm, how to create a calculator in python
how to create a calculator in python


How do you make your own calculator by Coding? - Dose this question come to your mind.

If you are a beginner in coding field than this blog can test your coding skills. In this blog you can learn how to make a normal calculator using Python.

I will create this calculator in Pycharm IDE using python programming language. For that you must have Python & Pycharm IDE installed on your PC. I will do coding using version 3.9 of Python.

1. How to install python ?

=> Go to Chrome > Type "Download python" > Install the new version or you can install any version of python.

2. How to install Pycharm ?

=> Go to Chrome > type "Install Pycharm" > Install it.

3. How to code a Calculator using python in Pycharm?

Follow these steps:

Step 1: Turn on your PC > Click 'Win+S' > Type "Pycharm" > Enter.

Step 2: Create a new file in Pycharm > Start Coding (follow the codes).

Source Code:

print("Welcome to Py Calculator by Rajtech99")

# Main Codes

while(True):

    number1 = int(input("Enter first number\n"))

    operator1 = input("Choose operator\n")

    number2 = int(input("Enter second number\n"))

    # \n is denotes the New line

    # Main Body

    if operator1 == '+':

        print("Sum of these numbers is - ", number1+number2)

    elif operator1 == '*':

        print("Multiplication of these numbers is - ", number1*number2)

    elif operator1 == '/':

        print("Division of these numbers is - ", number1/number2)

    elif operator1 == '-':

        print("Subtraction of these numbers is - ", number1-number2)

    else:

        print("Invalid statement, please input correct statement")


The Calculator is ready. Go to save as and save it in your pc.


You can alos convert it .py to .exe file using pyinstaller. This way
you can run this .exe file by loading any PC. For that, this file can
be run without any python or pycharm just like all other .exe files.
just double click on the file and run it.

4. How to install pyinstaller ?
=> Right click on windows button > Open windows powershell > Type "pip
install pyinstaller" > Enter.

5. How to convert it .py to .exe file ?
=> Go to the directory where your '.py' file is located > Press the shift
and simultaneously right-click at the same location > Open PowerShell window
here > Type 'pyinstaller --onefile -w "filename.py"' > if this process
complete > close the Powershell > open 'dist' file > Here you will get your
".exe" file.

About Python- Python is an interpreted high-level general-purpose

programming language. Its design philosophy emphasizes code

readability with its use of significant indentation.

More About Python: Wikipedia

First appeared- Feb 20, 1991

Designed by- Guido van Rossum


Raj Manna

My name is Raj. I am a student of 1st year physics honorus.

1 Comments

If you have any doubts, Please let me know

Post a Comment
Previous Post Next Post