Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def do_calculation():
- # Calculation_code
- print("Lets " + command + " some numbers. ")
- input1 = input("Length >1 ")
- input2 = input("Length >2 ")
- Length1 = int(input1)
- Length2 = int(input2)
- # Addition
- if command == "add" or command == "Add" or command == "Plus" or command == "plus":
- result = Length1 + Length2
- operator = " + "
- # Substaraction
- elif command == "Subtract" or command == "subtract" or command == "Minus" or command == "minus":
- result = Length1 - Length2
- operator = " - "
- # Multiplication
- elif command == "Multiply" or command == "multiply" or command == "Times" or command == "times":
- result = Length1 * Length2
- operator = " * "
- # Division
- elif command == "Divide" or command == "divide":
- result = Length1 / Length2
- operator = " / "
- output = str(result)
- print(input1 + operator + input2 + " = " + output)
- ##############################################################
- def Average():
- how_many = input("How many numbers would you like to average? ")
- 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 is = " + str(result))
- #####################################################################
- def total():
- how_many = input("How many shopping items do you have? ")
- how_many = int(how_many)
- shopping = []
- count = 0
- for item_number in range(how_many):
- item = input("what is item number " + str(item_number) + "? ")
- shopping.append(item)
- count = count + 1
- output = str(count)
- print("You have " + output + " items in your shopping list")
- print(shopping)
- def drink():
- how_many = input("How many drinks have you had? ")
- how_many = int(how_many)
- shopping = []
- count = 0
- for item_number in range(how_many):
- item = input("what was drink number " + str(item_number) + "? ")
- shopping.append(item)
- count = count + 1
- output = str(count)
- print("You've had " + output + " drinks, and they are ")
- print(shopping)
- print("** Hic**")
- finished = False
- while finished == False:
- print("Hi, I'm Tricky, your personal bot")
- print("OK , so lets get started!")
- # Ask the user to enter their name
- users_name = input("What is your name? ")
- print("Hi " + users_name + ", hope your having a great day!")
- # Ask the user to enter a choice to proceed
- command = input("I can help you with some shopping by creating a shopping list, or, would you like to do a spot of maths? I can Add, Subtract, Multiply, Divide or Average , or would you like a drink?. What would you like to do? ")
- # Add
- if command == "add" or command == "Add" or command == "Plus" or command == "plus":
- do_calculation()
- # Subtract
- elif command == "Subtract" or command == "subtract" or command == "Minus" or command == "minus":
- do_calculation()
- # Multiply
- elif command == "Multiply" or command == "multiply" or command == "Times" or command == "times":
- do_calculation()
- #Divide
- elif command == "Divide" or command == "divide":
- do_calculation()
- # Average
- elif command == "Average" or command == "average" or command == "Ave" or command == "ave":
- Average()
- # Shopping
- elif command == "Shopping" or command == "shopping" or command == "Shop" or command == "shop":
- total()
- # Drinking
- elif command == "gimme a drink" or command == "Drink" or command == "booze me up" or command == "I'd like a coldie":
- drink()
- # Goodbye
- elif command == "Cya" or command == "Bye" or command == "cya" or command == "bye":
- finished = True
- # Correct choice not made
- else:
- print("Thanks for playing with me!")
- print("cya")
- Hi, I'm Tricky, your personal bot
- OK , so lets get started!
- What is your name? Gary
- Hi Gary, hope your having a great day!
- I can help you with some shopping by creating a shopping list, or, would you like to do a spot of maths? I can Add, Subtract, Multiply, Divide or Average , or would you like a drink?. What would you like to do? average
- How many numbers would you like to average? 3
- Enter number0> 3
- Enter number1> 4
- Enter number2> 5
- The average is = 4.0
- cya
- Hi, I'm Tricky, your personal bot
- OK , so lets get started!
- What is your name? Gary
- Hi Gary, hope your having a great day!
- I can help you with some shopping by creating a shopping list, or, would you like to do a spot of maths? I can Add, Subtract, Multiply, Divide or Average , or would you like a drink?. What would you like to do? shop
- How many shopping items do you have? 5
- what is item number 0? bread
- what is item number 1? Milk
- what is item number 2? butter
- what is item number 3? Soap
- what is item number 4? Paper
- You have 5 items in your shopping list
- ['bread', 'Milk', 'butter', 'Soap', 'Paper']
- cya
- Hi, I'm Tricky, your personal bot
- OK , so lets get started!
- What is your name? cya
- Hi cya, hope your having a great day!
- I can help you with some shopping by creating a shopping list, or, would you like to do a spot of maths? I can Add, Subtract, Multiply, Divide or Average , or would you like a drink?. What would you like to do? cya
- cya
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement