Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Hi, I am Marvin, your personal bot.")
- phrase = input("Whats your name ? >")
- print(" Morning " + phrase)
- print("Do you want to divide, multiply , add or substract. OR average ?")
- command = input("How can I help ? >")
- if command == "divide" or command == "plus":
- print("Let's divide 2 numbers.")
- input1 = input("Number 1> ") # input numbers are strings#
- input2 = input("Number 2> ")
- number1 = int(input1) # use int to convert string to integer#
- number2 = int(input2)
- result = number1 / number2 # by using add #
- output = str(result) # result of operation#
- print(input1 + " / " + input2 + " = " + output)
- elif command == "multiply":
- print(" Let's multiply 2 numbers.")
- input1 = input("Number 1> ")
- input2 = input("Number 2> ")
- number1 = int(input1)
- number2 = int(input2)
- result = number1 * number2
- output = str(result)
- print(input1 + " * " + input2+" = " + output)
- elif command == "add":
- print(" Let's add 2 numbers.")
- input1 = input("Number 1> ")
- input2 = input("Number 2> ")
- number1 = int(input1)
- number2 = int(input2)
- result = number1 + number2
- output = str(result)
- print(input1 + " + " + input2+" = " + output)
- elif command == "substract":
- print(" Let's substract 2 numbers.")
- input1 = input("Number 1> ")
- input2 = input("Number 2> ")
- number1 = int(input1)
- number2 = int(input2)
- result = number1 - number2
- output = str(result)
- print(input1 + " - " + input2+" = " + output)
- elif command == "average":
- print("NOW find 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)
- result = total /how_many
- print("the average = " + str(result))
- else:
- print("Sorry I don't understand")
- print("Well done" + phrase)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement