Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- print("Hi, I am Marvin, your personal bot.")
- print("You can select one word of the menu, writing the word")
- print("add subtract multiply divide volume average")
- command = input("How can I help? ")
- if command == "add" or command == "plus": # Adding code to add in lines 8-16
- print("lets add two numbers")
- input1 = input("Number 1> ")
- input2 = input("Number 2> ")
- number1 = float(input1)
- number2 = float(input2)
- result = number1 + number2
- output = str(result)
- print(input1 + " + " + input2 + " = " + output)
- elif command == "subtract": # Adding code to subtract in lines 18-26
- print("lets subtract two numbers")
- input1 = input("Number 1> ")
- input2 = input("Number 2> ")
- number1 = float(input1)
- number2 = float(input2)
- result = number1 - number2
- output = str(result)
- print(input1 + " - " + input2 + " = " + output)
- elif command == "multiply" or command == "multiplication": # Adding code to multiply in lines 28-36
- print("lets multiply two numbers")
- input1 = input("Number 1> ")
- input2 = input("Number 2> ")
- number1 = float(input1)
- number2 = float(input2)
- result = number1 * number2
- output = str(result)
- print(input1 + " * " + input2 + " = " + output)
- elif command == "divide" or command == "division": # Adding code to divide in lines 38-46
- print("lets divide two numbers")
- input1 = input("Number 1> ")
- input2 = input("Number 2> ")
- number1 = float(input1)
- number2 = float(input2)
- result = number1 / number2
- output = str(result)
- print(input1 + " / " + input2 + " = " + output)
- elif command == "Volume" or command == "volume": # Adding code to volume in lines 48-57
- print("lets calculate volume of cylinder with 2 values, ratio and high in cms.")
- input1 = input("ratio > ")
- input2 = input("high > ")
- ratio = float(input1)
- high = float(input2)
- #pi1 = 3.14
- result = math.pi * ratio * ratio * high
- output = str(result)
- print("volume of cylinder = " + output + " cms^3")
- elif command == "average" or command == "Average": # Adding code to average in lines 59-68
- print("lets calculate the average of some numbers!")
- 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 dont understand")
Advertisement
Add Comment
Please, Sign In to add comment