Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Some functions
- input1=0
- input2=0
- result=0
- how_many=0
- total=0
- def do_calc():
- global input1
- input1 = int(input("Number 1> "))
- global input2
- input2 = int(input("Number 2> "))
- def do_list():
- how_many = input("How many numbers> ")
- how_many = int(how_many)
- global total
- total = 0
- global result
- for number_count in range(how_many):
- number = input("Enter number " + str(number_count) + "> ")
- total = total + int(number)
- result = total / how_many
- # BOT Presentation Shopping
- print("Hi, I am Marvin, your personal bot.")
- finished=False
- #input to ask which opetarion you want to do
- while finished==False:
- command = input("How can I help? ")
- # if operation is add else substract
- if command == "add":
- print("lets add some numbers")
- do_calc()
- result = input1 + input2
- #operates with the input and print result
- print(input1," + " ,input2," = " ,result)
- elif command == "subtract":
- print("lets subtract some numbers")
- do_calc()
- #operates with the input and print result
- result = input1 - input2
- print(input1," - " ,input2," = " ,result)
- elif command == "multiply":
- print("lets subtract some numbers")
- do_calc()
- #operates with the input and print result
- result = input1 * input2
- print(input1," * " ,input2," = " ,result)
- elif command == "divide":
- print("lets subtract some numbers")
- do_calc()
- #operates with the input and print result
- result = input1 / input2
- print(input1," / " ,input2," = " ,result)
- elif command == "average":
- do_list()
- print("the average = " + str(result))
- elif command == "total":
- do_list()
- print("the total = " + str(total))
- elif command=="discount":
- how_many = int(input("Which is the price > "))
- discount = int(input("Which is the discount > "))
- print ("The discount is ",discount/100*how_many," and the final prices is", how_many*(1-discount/100))
- elif command=="meal":
- print("Let's calculate the cost of meal")
- how_many = int(input("How many you are > "))
- discount = int(input("Which is the addition value > "))
- print ("The price per person is",discount/how_many )
- elif command=="bye":
- finished=True
- else:
- print("sorry I dont understand")
- #print polite error message in case nothing matchs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement