Advertisement
Roddyn

bot_add_subtract_notUnderstand_with_comments

Dec 9th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. print("Hi, I am Marvin, your personal bot.")
  2.  
  3. #asks and prints users name
  4. user_name = input ("What is your name? ")
  5. print("Welcome " + user_name )
  6.  
  7. #input a calculation type
  8. command = input("How can I help? ")
  9.  
  10. #when input add does an addition calculation
  11. if command == "add":
  12. print("let's add some numbers")
  13. input1 = input("Number 1> ")
  14. input2 = input("Number 2> ")
  15. number1 = int(input1)
  16. number2 = int(input2)
  17. result = number1 + number2
  18. output = str(result)
  19. print(input1 + " + " + input2 + " = " + output)
  20.  
  21. #when input suntract does a suntraction calculation
  22. elif command == "subtract":
  23. print("let's subtract some numbers")
  24. input1 = input("Number 1> ")
  25. input2 = input("Number 2> ")
  26. number1 = int(input1)
  27. number2 = int(input2)
  28. result = number1 - number2
  29. output = str(result)
  30. print(input1 + " - " + input2 + " = " + output)
  31.  
  32. # if neither add or subtract outputs an apology
  33. else:
  34. print ("sorry I can't do that yet!!!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement