INTRODUCTION
Python is very useful and very easy and simple to use programming language other than C++,C#,C language,Java etc.
In Python you can easily make many things are like game development, etc.
There are many ways to make a calculator in Python but I will give you a simple and easy to make a calculator in Python.
There are some Steps to Make A calculator in Python .
So, Let's Begin.
STEP1:- USE INPUT() METHOD TO ADD TWO NUMBERS.
In Python. You should use input() method to enter any number or a string but when we make a calculator we should use numbers because number will be add not String. So, we will use one more function to print any number that is int() method to enter any number or a integers. I will give you an example how to add and save it with "calculator.py" name.
For example :-
Num 1 =int( input("Enter First No.))
Num2 = int(input("Enter Second No."))
Output:-
Enter First Number :10Enter Second Number: 5
I think you understand that How Enter any two numbers but you don't know How to print two numbers and add these two Numbers.
For Example:-
Num1=int (input("Enter first No."))
Num2=(input(" Enter Second No.")). Print(Num1+Num2)
Output:-
Step:-Some instructions to use in python
Similarly,You will give input to subtract ,Multiplication ,Division etc. And save it'Calculatoropy"name.
For Example:-
Print(Num1-Num2)
Print(Num1/Num2)
Print (Num1*Num2)
Output:-
Step3:- Giving statement to make a calculator. Statement
Now, You can give to make a calculation.Give statement are like.
For Example:-
Print ("Enter + sign to Addition")
Print ("Enter - sign to Subtract" )
Print ("Enter * sign to Multiple")
Print ("Enter /sign to Divide).
Sign = input ("Enter your Sign")
Output:-
Step4:- Giving Condition :-
There are many statement in Python but we you if & else & elif statement to make a calculator.For Example:-
Print ("Enter + sign to addition")
Print ("Enter - sign to Subtract)
Print("Enter / sign to Divide)
Print ("Enter * sign to Multiple")
Sign =input ("Enter Your Sign")
Num1= int (input("Enter First No."))
Num2 = int(input("Enter Second No.")
if Sign = = "+":
Print (Num1,"+",Num2,"=",(Num1 + Num2))
Output:-
STEP5:- FINALLY MAKE A CALCULATOR WITH PYTHON
Finally, you make a calculator with the help of python once you make a calculator You should save "Calculator.py".
I Hope you like it.
Comments
Post a Comment
If you any doubts please comment