Advertisement
ykcr

bot5

Oct 22nd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.74 KB | None | 0 0
  1. # add the math library module
  2.  
  3. import math
  4.  
  5. print("Hi, I am Rosie, your personal bot.")
  6. print("How can I help?")
  7. command = input("Type add, subtract, multiply, divide, or type area to find the area of a circle.")
  8.  
  9. if command == "add":
  10.   print("Let\'s add some numbers.")
  11.   input1 = input("Number 1> ")
  12.   input2 = input("Number 2> ")
  13.   number1 = int(input1)
  14.   number2 = int(input2)
  15.   result = number1 + number2
  16.   output = str(result)
  17.   print(input1 + " plus " + input2 + " = " + output)
  18.  
  19. elif command == "subtract":
  20.   print("Let\'s subtract some numbers.")
  21.   input1 = input("Number 1> ")
  22.   input2 = input("Number 2> ")
  23.   number1 = int(input1)
  24.   number2 = int(input2)
  25.   result = number1 - number2
  26.   output = str(result)
  27.   print(input1 + " minus " + input2 + " = " + output)
  28.  
  29. elif command == "multiply":
  30.   print("Let\'s multiply some numbers.")
  31.   input1 = input("Number 1> ")
  32.   input2 = input("Number 2> ")
  33.   number1 = int(input1)
  34.   number2 = int(input2)
  35.   result = number1 * number2
  36.   output = str(result)
  37.   print(input1 + " times " + input2 + " = " + output)
  38.  
  39. elif command == "divide":
  40.   print("Let\'s divide some numbers.")
  41.   input1 = input("Number 1> ")
  42.   input2 = input("Number 2> ")
  43.   number1 = int(input1)
  44.   number2 = int(input2)
  45.   result = number1 / number2
  46.   output = str(result)
  47.   print(input1 + " divided by " + input2 + " = " + output)
  48.    
  49. elif command == "area":
  50.   print("Let\'s find the area of a circle.")
  51.   print("The area of a circle is pi times its radius squared.")
  52.   input1 = input("Radius > ")
  53.   number1 = float(input1)
  54.   result = math.pi * number1 * number1
  55.   output = str(result)
  56.   print("The area of the circle = " + output)
  57. else:
  58.   print("Sorry, I don't understand.")
  59. print("Thanks. Try another!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement