Here is what I have so far:
#! /usr/bin/python3
print("Welcome to the vCulator")
def menu():
print("Choose one of the following options:")
print("1. Add")
print("2. Subtract")
print("3. Multiply")
print("4. Divide")
print("0. Exit")
option=eval(input("Options: "))
def add(x=eval(input("This: ")), y=eval(input("Plus this: "))):
add_total=float(x)+y
print("Equals this:", add_total)
def subtract(x=eval(input("This: ")), y=eval(input("Minus this: "))):
subtract_total=float(x)-y
print("Equal this:", subtract_total)
def multiply(x=eval(input("This: ")), y=eval(input("Times this: "))):
multiply_total=float(x)*y
print("Equal this:", multiply_total)
def divide(x=eval(input("This: ")), y=eval(input("Divided by this: "))):
divide_total=float(x)/y
print("Equal this:", divide_total)
def main():
menu()
if option==1:
add(x,y)
elif option==2:
subtract(x,y)
elif option==3:
multiply(x,y)
elif option==4:
divide(x,y)
else:
print("Something went wrong! Try again")
return menu()
main()
It is supposed to call function main() and then that supposed to call function menu() and we're supposed to choose an option and go on from there based on the option.
Aucun commentaire:
Enregistrer un commentaire