Building a calculator in Python

in #coding5 years ago

We can build a calculator with the help of Python. It is not complex or hard to execute code.

Please follow the screenshots and try to play with the code as I have done with the help of Google's colab.

The first step is to write the commands so that the user can input values.

Capture.JPG

op stands for operator

All four operators are used in the code.

invalid.JPG

An else statement is also written in case a user inputs an invalid one.

Addition

addition.JPG

Subtraction

minus.JPG

Multiplication

multiply.JPG

Division

divison.JPG

Invalid

inva;id.JPG

I hope the screenshots were clear enough and easy to understand.

All images are screenshots of practice done on colab

Sort:  

!giphy cool




giphy is supported by witness untersatz!

Coin Marketplace

STEEM 0.23
TRX 0.25
JST 0.038
BTC 95511.18
ETH 3313.19
USDT 1.00
SBD 3.30