crzcas

boot with average

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