Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Hi, I am Marvin, your personal bot.")
- #asks and prints users name
- user_name = input ("What is your name? ")
- print("Welcome " + user_name )
- #input a calculation type
- command = input("How can I help? ")
- #when input add does an addition calculation
- if command == "add":
- print("let's add some numbers")
- input1 = input("Number 1> ")
- input2 = input("Number 2> ")
- number1 = int(input1)
- number2 = int(input2)
- result = number1 + number2
- output = str(result)
- print(input1 + " + " + input2 + " = " + output)
- #when input subtract does a suntraction calculation
- elif command == "subtract":
- print("let's subtract some numbers")
- input1 = input("Number 1> ")
- input2 = input("Number 2> ")
- number1 = int(input1)
- number2 = int(input2)
- result = number1 - number2
- output = str(result)
- print(input1 + " - " + input2 + " = " + output)
- #when input multiply does a multiply calculation
- elif command == "multiply":
- print("let's Multiply some numbers")
- input1 = input("Number 1> ")
- input2 = input("Number 2> ")
- number1 = int(input1)
- number2 = int(input2)
- result = number1 * number2
- output = str(result)
- print(input1 + " * " + input2 + " = " + output)
- #when input subtract does asubtraction calculation
- elif command == "subtract":
- print("let's subtract some numbers")
- input1 = input("Number 1> ")
- input2 = input("Number 2> ")
- number1 = int(input1)
- number2 = int(input2)
- result = number1 - number2
- output = str(result)
- print(input1 + " - " + input2 + " = " + output)
- #when input triangle calculates the are of a right angled triangle
- elif command == "triangle":
- print("let's find the area of a right angled triangle")
- input1 = input("Base of the triangle> ")
- input2 = input("Height of the triangle> ")
- number1 = int(input1)
- number2 = int(input2)
- result = (number1 * 0.5) * number2
- output = str(result)
- print("(" + input1 + " * 0.5) *" + input2 + " = " + output)
- # if neither add or subtract outputs an apology
- else:
- print ("sorry I can't do that yet!!!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement