Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # I want this program to help with simple calculations
- print ("Hi, I am Marvin, your personal bot")
- command = input ("How can I help? I can add, subtract, multiply or divide. You choose.")
- # The user can choose between the options Marvin gives
- if command == "add":
- input1 = input("Number 1> ")
- input2 = input("Number 2> ")
- number1 = float(input1)
- number2 = float(input2)
- result = number1 + number2
- output = str(result)
- print(input1 + " + " + input2 + " = " + output)
- # the next option is subtraction
- elif command == "subtract":
- input1 = input("number1>")
- input2 = input("number2>")
- number1 = float(input1)
- number2 = float(input2)
- result = number1 - number2
- output = str(result)
- print(input1 + " - " + input2 + " = " + output)
- # the next option is multiplication
- elif command == "multiply":
- input1 = input("number1>")
- input2 = input("number2>")
- number1 = float(input1)
- number2 = float(input2)
- result = number1 * number2
- output = str(result)
- print(input1 + "*" + input2 + "=" + output)
- # the next option is dividing the height and width of a structure
- elif command == "divide":
- input1 = input("number1>")
- input2 = input("number2>")
- number1 = float(input1)
- number2 = float(input2)
- result = number1/number2
- output = str(result)
- print(input1 + "/" + input2 + "=" + output)
- # finally, the next option is calculating the area of a room so that you can order a carpet
- elif command == "area":
- input1 = input("number1>")
- input2 = input("number2>")
- number1 = float(input1)
- number2 = float(input2)
- result = number1 * number2
- output = str(result)
- print("You will need to ask the carpet supplier for a carpet with an area of " + output + " square metres")
- # or if the user input doesn't match then tell them
- else:
- print("I don't understand")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement