Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Adding more code to add, subtract, multiply, divide two numbers, and calculate the volume of a cylinder
- 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")
- command = input("How can I help? ")
- if command == "add" or command == "plus": # Adding code to add in lines 9-17
- 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 19-27
- 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 29-37
- 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 39-47
- 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 subtract in lines 49-58
- 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")
- else:
- print("sorry I dont understand")
Add Comment
Please, Sign In to add comment