Calculator Challange Python Coding Create a simple calculator that takes in TWO numbers from the user and then asks the user to select if they want to ADD, SUBTRACT, MULTIPLY or DIVIDE to get the answer. I have coded... print("input whole numbers please, no decimals")again=""while again!="N":first=int(input("What is the first number?"))last=int(input("What is the last number?"))#let user pick the operation, assign numbers to the operationsoperation=int(input("Would you like to 1) add, 2)subtract, 3)multiply, or 4) divide?"))if operation==1:answer=first+lastelif operation==2:answer=first-lastelif operation ==3:answer=first*lastelif operation == 4:answer=first/lastelse:print("You did something wrong, try again.")print("The answer: %s"%(answer))again=str(input("Would you like to go again? Y/N")).upper()same=str(input("Would you like to use the same two numbers? Y/N")).upper()while same=="Y":operation = int(input("Would you like to 1) add, 2)subtract, 3)multiply, or 4) divide?"))if operation == 1:answer = first + lastelif operation == 2:answer = first - lastelif operation == 3:answer = first * lastelif operation == 4:answer = first / lastelse:print("You did something wrong, try again.")print("The answer: %s" % (answer))again = str(input("Would you like to go again? Y/N")).upper()same = str(input("Would you like to use the same two numbers? Y/N")).upper() Finish the coding to... -the numbers inputted and the answers are written into a text file -output to the text file the full sentence of what operations you are doing. For example output to the text file : 2 x 3 = 6
Calculator Challange
Python Coding
Create a simple calculator that takes in TWO numbers from the user and then asks the user to select if they want to ADD, SUBTRACT, MULTIPLY or DIVIDE to get the answer.
I have coded...
print("input whole numbers please, no decimals")
again=""
while again!="N":
first=int(input("What is the first number?"))
last=int(input("What is the last number?"))
#let user pick the operation, assign numbers to the operations
operation=int(input("Would you like to 1) add, 2)subtract, 3)multiply, or 4) divide?"))
if operation==1:
answer=first+last
elif operation==2:
answer=first-last
elif operation ==3:
answer=first*last
elif operation == 4:
answer=first/last
else:
print("You did something wrong, try again.")
print("The answer: %s"%(answer))
again=str(input("Would you like to go again? Y/N")).upper()
same=str(input("Would you like to use the same two numbers? Y/N")).upper()
while same=="Y":
operation = int(input("Would you like to 1) add, 2)subtract, 3)multiply, or 4) divide?"))
if operation == 1:
answer = first + last
elif operation == 2:
answer = first - last
elif operation == 3:
answer = first * last
elif operation == 4:
answer = first / last
else:
print("You did something wrong, try again.")
print("The answer: %s" % (answer))
again = str(input("Would you like to go again? Y/N")).upper()
same = str(input("Would you like to use the same two numbers? Y/N")).upper()
Finish the coding to...
-the numbers inputted and the answers are written into a text file
-output to the text file the full sentence of what operations you are doing. For example output to the text file :
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 4 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)