Making A Simple Calculator In Python

Calculator in python
Table of Contents

Hello coders today we are going to make a simple calculator in python this project is for beginners and everyone should make it.

Making a calculator in python is very simple and easy you can try to create it on your own but if you can’t follow this tutorial I will give you the source code of the python calculator.

This is just a basic calculator you will be able to do simple calculations like addition, subtraction, multiply and divide.

If you are intrested in making projects or want some source code of projects you can check out the projects that I have created and you can get the source for free you can go here – Coderzway Projects.

Let’s make a calculator in python

So Inorder to run and write python you will require python installed on your machine I am sure you are reading this article after installing python.

But if you don’t have python installed you can install it from here – Download python. Remember to click add python to path while installing.

I will be using vs code editor to edit and write code you can use anything I will recommend you to use vs code – download vs code.

So let’s start

Go to any folder and create and python file with .py extension

inside the file copy and paste this code

					print('Welcome to Python Calculator by Coderzway')

def add(num1,num2):
    print(int(num1) + int(num2))
def subtract(num1,num2):
    print(int(num1) - int(num2))
def multiply(num1,num2):
    print(int(num1) * int(num2))
def divide(num1,num2):
    print(int(num1) / int(num2))

def take_inputs():
    num1 = int(input('Enter a number: '))
    num2 = int(input('Enter another number: '))
    return [num1,num2]

res = input('''What you want to do
    For Addition click +
    For Subtraction click -
    For Multiply click *
    For Divide click /
    For Exiting click e

if res == '*':
    num = take_inputs()
    multiply(num[0], num[1])
elif res == '/':
    num = take_inputs()
    divide(num[0], num[1])
elif res == '+':
    num = take_inputs()
    add(num[0], num[1])
elif res == '-':
    num = take_inputs()
    subtr(num[0], num[1])
elif res == 'e':


You can run this code by opening command prompt at the file location and type python in the command prompt this will give you this.



Calculator in python

So you need to click any of the button from given

*  is for multiplication
+ is for addition
–  is for subtraction
/  is for divide

After that you need to enter the numbers you want to calculate you can change and add new features to this calculator.

Thanks for reading I hope you found what you were looking for and If you want more projects like this subscribe to our newsletter.

Share This Post
Share on facebook
Share on twitter
Share on email
Share on whatsapp

Leave a Reply

Subscribe To Our Newsletter

Get updates and learn from the best

Latest Guides & Articles