crzcas

add, subtract, multiply, divide, volume

Nov 28th, 2020 (edited)
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.25 KB | None | 0 0
  1. # Adding more code to add, subtract, multiply, divide two numbers, and calculate the volume of a cylinder
  2. import math
  3.  
  4. print("Hi, I am Marvin, your personal bot.")
  5. print("You can select one word of the menu, writing the word")
  6. print("add   subtract   multiply   divide   volume")
  7. command = input("How can I help? ")
  8.  
  9. if command == "add" or command == "plus":   # Adding code to add in lines 9-17    
  10.     print("lets add two numbers")
  11.     input1 = input("Number 1> ")
  12.     input2 = input("Number 2> ")
  13.     number1 = float(input1)
  14.     number2 = float(input2)
  15.     result = number1 + number2
  16.     output = str(result)
  17.     print(input1 + " + " + input2 + " = " + output)
  18.    
  19. elif command == "subtract":   # Adding code to subtract in lines 19-27  
  20.     print("lets subtract two numbers")
  21.     input1 = input("Number 1> ")
  22.     input2 = input("Number 2> ")
  23.     number1 = float(input1)
  24.     number2 = float(input2)
  25.     result = number1 - number2
  26.     output = str(result)
  27.     print(input1 + " - " + input2 + " = " + output)
  28.    
  29. elif command == "multiply" or command == "multiplication":   # Adding code to multiply in lines 29-37  
  30.     print("lets multiply two numbers")
  31.     input1 = input("Number 1> ")
  32.     input2 = input("Number 2> ")
  33.     number1 = float(input1)
  34.     number2 = float(input2)
  35.     result = number1 * number2
  36.     output = str(result)
  37.     print(input1 + " * " + input2 + " = " + output)
  38.  
  39. elif command == "divide" or command == "division":   # Adding code to divide in lines 39-47  
  40.     print("lets divide two numbers")
  41.     input1 = input("Number 1> ")
  42.     input2 = input("Number 2> ")
  43.     number1 = float(input1)
  44.     number2 = float(input2)
  45.     result = number1 / number2
  46.     output = str(result)
  47.     print(input1 + " / " + input2 + " = " + output)  
  48.  
  49. elif command == "Volume" or command == "volume":   # Adding code to subtract in lines 49-58  
  50.     print("lets calculate volume of cylinder with 2 values, ratio and high in cms.")
  51.     input1 = input("ratio > ")
  52.     input2 = input("high > ")
  53.     ratio = float(input1)
  54.     high = float(input2)
  55.     #pi1 = 3.14
  56.     result = math.pi * ratio * ratio * high
  57.     output = str(result)
  58.     print("volume of cylinder = " + output + " cms^3")    
  59.    
  60. else:
  61.     print("sorry I dont understand")
Add Comment
Please, Sign In to add comment