Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def do_calculation():
- input1 = input("Input number 1 ")
- input2 = input("Input number 2 ")
- number1 = int(input1)
- number2 = int(input2)
- if command == "+":
- result = number1 + number2
- print ("Result is " + str(result))
- elif command == "-":
- result = number1 - number2
- print ("Result is " + str(result))
- elif command == "x":
- result = number1 * number2
- print ("Result is " + str(result))
- elif command == "/":
- result = number1 / number2
- operator = "/ "
- output = str(result)
- print(input1 + operator + input2 + " = " + output)
- def do_average():
- how_many = input("How many numbers? ")
- how_many = int(how_many)
- total = 0
- for number_count in range(how_many):
- number = input("Enter number " + str(number_count) + " ")
- total = total + int(number)
- output = total/how_many
- print("The average = " + str(output))
- finished = False
- while finished == False:
- print ("Hi, I am Doris your personal Bot.")
- command = input("What would you like to do - add (+), subtract (-), multiply (x), divide (/)or average (aver)? ")
- if command == "add" or command == "+":
- do_calculation()
- elif command == "subtract" or command == "-":
- do_calculation()
- elif command == "multiply" or command == "x":
- do_calculation()
- elif command == "divide" or command == "/":
- do_calculation()
- elif command == "average" or command == "aver":
- do_average()
- elif command == "bye":
- finished = True
- print ("Goodbye")
- else:
- print("Sorry I don't understand")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement