I was asked to write a calculator in Python, and I completed it, but there is only one issue that needs to be fixed.
What is the prerequisite? "Once the user inputs/selects an arithmetic operation, the program should ask the user to enter the two operands one by one, separated by Enter key. If the user made a mistake while entering the parameters, he can return to main menu by pressing ‘$’ key at the end of the input string, followed by the Enter key.
I'll give you the code I wrote here, and I'd appreciate it if you could make this to get the return function.
def Add(a, b):return a + b# Function to subtract two numbers
def Subtract(a, b):return a - b# Function to multiply two numbers
def Multiply(a, b):return a * b# Function to divide two numbers
def Divide(a, b):return a / b# Function to power two numbers
def Power(a, b):return a ** b# Function to remaind two numbers
def Remainder(a, b):return a % bdef Reset(a,b):return print(choice)while True:print("Select operation.")print("1.Add : + ")print("2.Subtract : - ")print("3.Multiply : * ")print("4.Divide : / ")print("5.Power : ^ ")print("6.Remainder: % ")print("7.Terminate: # ")print("8.Reset : $ ")# take input from the userchoice = input("Enter choice(+,-,*,/,^,%,#,$): ")print(choice)if choice in ('+', '-', '*', '/', '^', '%', '#', '$'):if choice == '#':print("Done. Terminating")breaka = input('Enter first number: ')print(str(a))b = input('Enter second number: ')print(str(b))if choice == '+':print(float(a), "+" ,float(b), "=", Add(float(a), float(b)))elif choice == '-':print(float(a), "-",float(b), "=", Subtract(float(a), float(b)))elif choice == '*':print(float(a), "*",float(b), "=", Multiply(float(a), float(b)))elif choice == '/':if int(b) != 0:print(float(a), "/", float(b), "=", Divide(float(a), float(b)))breakelse:print("float division by zero")print(float(a), "/", float(b), "=", "None")elif choice == '^':print(float(a), "**",float(b), "=", Power(float(a), float(b)))elif choice == '%':print(float(a), "%",float(b), "=", Remainder(float(a), float(b)))breakelse:print('Not a valid number,please enter again.')```