Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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" or command == "plus":
- result = number1 + number2
- operator = " + "
- elif command == "subtract" or command == "minus":
- result = number1 - number2
- operator = " - "
- elif command == "multiply" or command == "times":
- result = number1 * number2
- operator = " * "
- elif command == "divide" or command == "division":
- result = number1 / number2
- operator = " / "
- output = str(result)
- print(input1 + operator + input2 + " = " + output)
- def Add_Them_Up():
- total = 0
- how_many = input("how many numbers would you like to enter? ")
- how_many = int(how_many)
- for item_number in range(how_many):
- number = input("Enter the number of " + str(item_number) + "> ")
- total = total + int(number)
- if command == "total":
- print("You have entered " + str(how_many) + " numbers. Your total is " + str(total))
- elif command == "average" or command == "avg":
- avg = total / int(how_many)
- print("You have entered " + str(how_many) + " numbers. Your average is " + str(avg))
- finished = False
- while finished == False:
- print("Hi, I am Zed, your personal bot.")
- command = input("How can I help (bye to end program)? ")
- if command == "add" or command == "plus":
- do_calculation()
- elif command == "subtract" or command == "minus":
- do_calculation()
- elif command == "multiply" or command == "times":
- do_calculation()
- elif command == "divide" or command == "division":
- do_calculation()
- elif command == "Area":
- print("lets calculate the area of a triangle")
- input1 = input("Base > ")
- input2 = input("Hypotenuse > ")
- number1 = int(input1)
- number2 = int(input2)
- result = (number1 * number2) / 2
- output = str(result)
- print("(Base:"+input1 + " * " + "Hypotenuse:"+input2 + ") / 2" + " = " + output)
- elif command == "average" or command == "avg":
- total = 0
- how_many = input("how many numbers? ")
- how_many = int(how_many)
- 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 == "shopping" or command == "shop":
- total = 0
- shopping = []
- how_many = input("how many items of shopping do you have? ")
- how_many = int(how_many)
- for item_number in range(how_many):
- item = input("what is the item " + str(item_number) + " ? ")
- number = input("Enter the cost of " + str(item) + "> ")
- total = total + int(number)
- shopping.append(item)
- print(shopping)
- print("You have " + str(how_many) + " items in your shopping list. Your total is " + str(total))
- elif command == "total":
- Add_Them_Up()
- elif command == "average" or "avg":
- Add_Them_Up()
- elif command == "bye":
- finished = True
- else:
- print("sorry I dont understand")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement