Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Hi I am John B, your personal bot.")
- print("lets get started.")
- print(" ")
- print(" ")
- users_name = input("How would you like to be addressed? ")
- print(" ")
- print(" ")
- print("Welcome " + users_name + " and lets go on an adventure")
- finished = False
- while finished == False:
- print("Available commands are - add or subtract or average or highest . ")
- print(" to stop the program enter quit.")
- command = input("Enter a command:- ")
- if command == "add" or command == "plus":
- input1 = input("number 1> ")
- number1 = int(input1)
- input2 = input("number 2> ")
- number2 = int(input2)
- result = number1 + number2
- print(" ")
- output = str(result)
- print(input1 + "+" + input2 + "=" + output)
- elif command == "subtract":
- input1 = input("number 1> ")
- number1 = int(input1)
- input2 = input("number 2> ")
- number2 = int(input2)
- result = number1 - number2
- print(" ")
- output = str(result)
- print(input1 + "-" + input2 + "=" + output)
- elif command == "average":
- how_many = input("How many numbers ? ")
- how_many = int(how_many)
- total = 0
- for number_count in range(how_many):
- number = input("Enter number " + str(number_count) + "> ")
- total = total+int(number)
- result = total/how_many
- print("The average = " + str(result))
- elif command == "highest":
- target = 0
- how_many = input("How many numbers ? ")
- how_many = int(how_many)
- total = 0
- for number_count in range(how_many):
- number = input("Enter number " + str(number_count) + "> ")
- # print("targ 1 " + str(target))
- if target < int(number):
- target = int(number)
- # print("targ 2 " + str(target))
- print("The highest = " + str(target))
- elif command == "quit":
- finished = True
- else:
- print("sorry not a valid command")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement