Skip to main content

Command Palette

Search for a command to run...

Calculator project with python

Made by Ian Fajobi-Omotosho

Published
•2 min read•View as Markdown
Calculator project with python
I

I am a developer,student from newham,london and just likes to play around with coding i am 11 years old

So I was doing my homework on operators when I came across a hard question so I thought to myself and said I wish I had a calculator and I remembered that I am a python programmer then I started programming a calculator.I used if statements, if else statements, functions and while loops. You would really like it.

DESCRIPTION

In this program, it will ask you to choose an operation. Options 1=addition, 2=subtraction, 3=multiplication, and 4=division are valid. If any other input is given, Invalid Input is displayed and the loop continues until a valid option is selected.

EXPLANATION OF CODE

  1. I used 4 functions 1 for add, 2 for subtract, 3 for multiplication and 4 for division and the return statement to make everything do what the operator you choose to do the calculation

  2. I then used a while loop which I set to true so that if you put an invalid input it will not work the code will run again until you put a valid input

  3. Then I used if and elif statements to make your choice do the calculation of the operator you choose, for example if you choose 1 it will show you enter first number and enter second number and it will show the numbers that you input, the operation and the answer.

  4. Then the program asks you if you want to do another calculation if you say no the code will stop but if you say yes the code will run again

HERE IS A LINK TO GO TO MY PROJECT

https://replit.com/@IanOmotosho/calculator-project