answersLogoWhite

0


Best Answer

An example might be:

firstNumber = raw_input("Enter your first number: ")

secondNumber = raw_input("Enter your second number: ")

operatorChoice = raw_input("What do you wish to do with these numbers? ")

if operatorChoice == "-":

subtractSum = firstNumber - secondNumber

print("Here is your result: %s") % (str(subtractSum))

if operatorChoice == "+":

additionSum = firstNumber + secondNumber

print("Here is your result: %s") % (str(additionSum))

That's a basic example.

User Avatar

Wiki User

7y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you code a calculator in python?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Code to develop a calculator in adobe flex?

here is the code for simple calculator in flex,[Bindable] private var _txt:Object;[Bindable] private var _choos:String;private function satu():void{txtLayar.text = txtLayar.text + '1';}private function dot():void{txtLayar.text = txtLayar.text + '.';}private function dua():void{txtLayar.text = txtLayar.text + '2';}private function tiga():void{txtLayar.text = txtLayar.text + '3';}private function empat():void{txtLayar.text = txtLayar.text + '4';}private function lima():void{txtLayar.text = txtLayar.text + '5';}private function enam():void{txtLayar.text = txtLayar.text + '6';}private function tujuh():void{txtLayar.text = txtLayar.text + '7';}private function lapan():void{txtLayar.text = txtLayar.text + '8';}private function sembilan():void{txtLayar.text = txtLayar.text + '9';}private function noll():void{txtLayar.text = txtLayar.text + '0';}private function clear():void{txtLayar.text = '';}private function sum():void{_txt = txtLayar.text;_choos = '1';txtLayar.text = '';}private function sub():void{_txt = txtLayar.text;_choos = '2';txtLayar.text = '';}private function mul():void{_txt = txtLayar.text;_choos = '3';txtLayar.text = '';}private function div():void{_txt = txtLayar.text;_choos = '4';txtLayar.text = '';}private function hasil():void{var txt2:Number = Number(txtLayar.text);var txt3:Number = Number(_txt);var has:Number;if(_choos=='1'){has = txt3 + txt2;}else if(_choos == '2'){has = txt3 - txt2;}else if(_choos == '3'){has = txt3 * txt2;}else if(_choos == '4'){has = txt3 / txt2;}txtLayar.text = has.toString();}]]>


Can you run a python program using code Can you give me the code I need to use in order for it to work I am using codio plz help?

Assuming you only intend executing your code on your own machine and you have some version of Python installed, you can execute a Python script from within your code in the same way you can execute a Python script via the command line: python script.py infile outfile -o


Can you delete code on python?

you can uninstall it just like any other program.


What is the source code for scientific calculator in c?

What is the source code for scientific calculator in c?Read more: What_is_the_source_code_for_scientific_calculator_in_c


What is the python code for drawing a circle?

circle(radius)


Download code for scientific calculator in java?

yes


Can you do Python coding on an iPad?

Sorry, but not that I know of. Python is only available on Mac OS or Windows. You would also need a code editor which is only on a PC.


Why doesn't this Python code do what it's supposed to do - see Discussion?

Ask on Stack Overflow. Wiki Answers is not for pasting code


What is the bonus code for iron man 3?

The bonus code for Iron Man 3 is: mark 20 python. However, you also can use other codes for bonuses, such as the words "striker missile".


How do you make a random number using Python?

this is the code for making a random number using python: import random >>>random.randint (1, 10) you can do whatever numbers you want.


How do you buy Car radio code calculator?

renrdw240-00


Blaupunkt SC 202 D code calculator?

90381123