Advertisement
David90278

Raspberry Pi - Programming 101 - Adding Comments

Feb 22nd, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.23 KB | None | 0 0
  1. # Introduce yourself to your visitor
  2. print("Hi, I am Rotellity, the Funky Maths bot.")
  3. print("I came, I saw, I added and subtracted!")
  4. # Ask the visitor a question.
  5. # Use inputs to collect their responses
  6. # Use number variables to convert the input replies into integers
  7. # Use output to convert the result into a string
  8. command = input("How can I help?")
  9. if command == "add" or command == "plus":
  10.     print("let's add some numbers")
  11.     input1 = input("Pick a number, any number!>")
  12.     input2 = input("Now pick a second number>")
  13.     number1 = int(input1)
  14.     number2 = int(input2)
  15.     result = number1 + number2
  16.     output = str(result)
  17.     print("Watch me add both numbers!" + input1 + " + " + input2 + " = " + output)
  18. elif command == "subtract" or command == "minus":
  19.     print("let's subtract some numbers")
  20.     input1 = input("Start by picking one number, any number!")
  21.     input2 = input("Now, pick a second number, any one will do!")
  22.     number1 = int(input1)
  23.     number2 = int(input2)
  24.     result = number1 - number2
  25.     output = str(result)
  26.     print("Watch me substract both numbers! " + input1 + " - " + input2 + " = " + output)
  27. else:
  28.     print("Sorry, I am but a simple maths bot. I do not understand your request.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement