Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def do_calc2():
- how_many = input("How many numbers ? ")
- how_many = int(how_many)
- total = 0
- result = 0
- for number_count in range(how_many):
- number = input("Enter number " + str(number_count) + "> ")
- total = total+int(number)
- if command == "average":
- result = total/how_many
- print("The average = " + str(result))
- elif command == "total":
- result = total
- print("The Total = " + str(result))
- def do_calculation():
- print("Lets " + command + " some numbers.")
- input1 = input("Number 1>")
- input2 = input("Number 2>")
- number1 = int(input1)
- number2 = int(input2)
- if command == "add":
- result = number1 + number2
- operator = " + "
- elif command == "subtract":
- result = number1 - number2
- operator = " - "
- output = str(result)
- print(input1 + operator + input2 + " = " + output)
- 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 total or highest. ")
- print(" to stop the program enter quit.")
- command = input("Enter a command:- ")
- if command == "add" or command == "plus":
- do_calculation()
- elif command == "subtract":
- do_calculation()
- elif command == "average":
- # how_many = input("How many numbers ? ")
- # how_many = int(how_many)
- total = 0
- # how_many = 0
- # for number_count in range(how_many):
- # number = input("Enter number " + str(number_count) + "> ")
- # total = total+int(number)
- do_calc2()
- # print(int(how_many))
- # result = total/how_many
- # print("The average = " + str(result))
- elif command == "total":
- # 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
- # print("The Total = " + str(result))
- do_calc2()
- 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":
- print("Thank you " + users_name + " and goodbye.")
- finished = True
- else:
- print("sorry not a valid command")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement