How to make a simple calculator with python
Hey guys! Welcome to my first blog post about python. Today im gonna show you how to make a calculator in Python! So first you will need a python editor or you can just go to online-python.com.
after you go there it will show something like this-
If you want dark mode click the moon button on the top right. then it will show something like this-
Then you can click on the plus button to get a new tab or console.
Then you can type the following code(remember do not start command with capital letter it wont work)
print("This is a calculator program made in python.")
num1 = int(input("Enter a number 1"))
num2 = int(input("Enter a number 2"))
operate = input("A,S,M or D")
if operate == "A":
total = num1 + num2
print("The sum of the two numbers is: ", total)
if operate == "S":
total = num1 - num2
print("The difference of two numbers is: ", total)
if operate == "M":
total = num1 * num2
print("the product of the two numbers is", total)
if operate == "D":
total = num1 / num2
print("the quotient of the two numbers is", total)
The program will look like this in the end(I have used addition as the input for the image)-
hey guys! hope you like this python tutorial. If you liked it then put it in the comments and more tutorials are coming!!
ReplyDelete