Skip to main content

How To make a Calculater


                    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 :10  
Enter 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:-

15


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:- 

5
2
50

 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:-

Enter + sign to add
Enter - sign to subtract
Enter / sign to Divide 
Enter * sign to Multiply 



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:- 

Enter -sign to subtract 
Enter +sign to add
Enter/ sign to Divide 
Enter * sign to Multiply 
10+5=15

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.

Notice:-

If you enter + sign so your output:- is 


Input:-

Print("enter + sign to add")
Print("enter - sign to Subtract")
Print("enter * sign to Multiply")
Print("enter / sign to Divide")

Sign=input("enter your sign")
Num1=int(input("enter first number"))
Num2=int(input("enter second number"))

If sign=="+":
 Print(Num1,"+",Num2,"=",(Num1+Num2)
elif sign=="-":
 print(Num1,"-",Num2,"=",(Num1-Num2)
elif sign=="/":
Print(Num1,"/",Num2,"=",(Num1/Num2)
else:
Print(Num1,"*",Num2,"=",(Num1*Num2)

Output:- 

enter + sign to add
enter - sign to subtract 
enter / sign to Divide 
enter * sign to Multiply 
15

Comments

Popular posts from this blog

How To Install Python?

 INTRODUCTION Before we talk about to install Python and which Python distribution to install, it is important to discuss whether to use Python 2.x or Python 3.x.  Python 2.x. vs. Python 3.x. Python 2.x. is a legacy version which was last released in 2010 (version 2.7.x.) and discontinued after that, but the support for this version remained for the sake of backward compatibility. Python 3.x. is considered the present and future edition of the language. Python 3.x. is a preferred version to use because of these :-  The overwhelming majority of third-party Python Library support Python 3.x. Python 3.x. has many features and performances benefits that aren't available in Python 2.x. Also, the differences in syntax between the two versions are fairly minimal. It won't take long to learn Python 2.x if ever you need to. Python Distributions Python is an interpretered language and you need Python interpreter to execute Python programs. As Python is becoming preferred choice for...

What is Python?

 There are many languages are like C++,C Languages, Java,Java scripts,C# etc. in computer that understand but Python is latest and very simple to Use.   The word Python -- isn't it scary? Does it bring the image of big reptile that we prefer to see either in jungle or zoo?                 What Is Python?   Python is an easy to learn and powerful object oriented programming language. It is a very high level programming language yet as powerful as many other middle level not so high-level language like C,C++,Java etc.  Introduction of  Python P ython the programming language. Was Named after  MONTY PYTHON FLYING CIRCUS. Python was influenced by Two Programming Languages:- ABC LANGUAGE MODULA-3 Python was invented by "Guido Van Rossum " & Invented in 1990               Advantage  of Python Easy to use( Python is compact and very easy to use object oriented language with ve...