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 :
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here