Advertisement
MartC

bot

Apr 5th, 2020
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.99 KB | None | 0 0
  1. #the following three print commands display a message upon launch
  2. print("Hi, I am Marvin, your personal bot.")
  3. print("I hope you are feeling well today.")
  4. print("OK, let's get started...")
  5. #this next step requires the user to input their name
  6. users_name = input ("What's your name? ")
  7. #the following print command displays the inputted text from the user
  8. #along with a welcome
  9. print("Welcome " + users_name + "!")
  10. #the next command asks what mathematical operation the user requires
  11. #with different code for adding, subtracting, multiplying  
  12. #and dividing(if and elif functions)
  13. command = input("What can I do for you? >")
  14. if command == "add" or command == "plus" or command == "+":
  15.     print("Let's add some numbers!")
  16.     input1 = input("Number 1 > ")
  17.     input2 = input("Number 2 > ")
  18.     number1 = int(input1)
  19.     number2 = int(input2)
  20.     result = number1 + number2
  21.     output = str(result)
  22.     print(input1 + " + " + input2 + " = " + output)
  23. elif command == "subtract" or command == "take away" or command == "-":
  24.     print("Let's subtract some numbers!")
  25.     input1 = input("Number 1 > ")
  26.     input2 = input("Number 2 > ")
  27.     number1 = int(input1)
  28.     number2 = int(input2)
  29.     result = number1 - number2
  30.     output = str(result)
  31.     print(input1 + " - " + input2 + " = " + output)
  32. elif command == "multiply" or command == "times" or command == "x":
  33.     print("Let's mulitply some numbers!")
  34.     input1 = input("Number 1 > ")
  35.     input2 = input("Number 2 > ")
  36.     number1 = int(input1)
  37.     number2 = int(input2)
  38.     result = number1 * number2
  39.     output = str(result)
  40.     print(input1 + " x " + input2 + " = " + output)
  41. elif command == "divide" or command == "share" or command == "/":
  42.     print("Let's divide some numbers!")
  43.     input1 = input("Number 1 > ")
  44.     input2 = input("Number 2 > ")
  45.     number1 = int(input1)
  46.     number2 = int(input2)
  47.     result = number1 / number2
  48.     output = str(result)
  49.     print(input1 + " / " + input2 + " = " + output)
  50. elif command == "area":
  51.     print("Let's find the area of a rectangle.")
  52.     input1 = input("Length of longer side in cm > ")
  53.     input2 = input("Length of shorter side in cm > ")
  54.     number1 = int(input1)
  55.     number2 = int(input2)
  56.     result = number1 * number2
  57.     output = str(result)
  58.     print("The area is " + input1 + "cm x " + input2 + "cm = " + output + "cm^2")
  59. elif command == "volume":
  60.     print("OK. How about the volume of a cuboid?")
  61.     input3 = input("Length of cuboid in cm > ")
  62.     input4 = input("Height of cuboid in cm > ")
  63.     input5 = input("Width of cuboid in cm > ")
  64.     number3 = int(input3)
  65.     number4 = int(input4)
  66.     number5 = int(input5)
  67.     result1 = number3 * number4 * number5
  68.     output1 = str(result1)
  69.     print("The volume is " + input3 + "cm x " + input4 + "cm x " + input5 + "cm = " + output1 + "cm^3")
  70. #the final "else" function displays a message if the required
  71. #command does not match any of those stated in the code above
  72. else:
  73.     print("I'm sorry, I don't understand...")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement