Advertisement
xavicano

Untitled

Oct 13th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.17 KB | None | 0 0
  1. # Some functions
  2. def do_calc():
  3.   input1 = int(input("Number 1> "))
  4.   input2 = int(input("Number 2> "))
  5.  
  6.  
  7. # BOT Presentation Shopping
  8. print("Hi, I am Marvin, your personal bot.")
  9. finished=False
  10. input1=0
  11. input2=0
  12.  
  13. #input to ask which opetarion you want to do
  14. command = input("How can I help? ")
  15.  
  16. while finished==False:
  17.  
  18.   # if operation is add else substract
  19.   if command == "add":
  20.       print("lets add some numbers")
  21.       do_calc()
  22.       result = input1 + input2
  23.       #operates with the input and print result
  24.       print(input1," + " ,input2," = " ,result)
  25.   elif command == "subtract":
  26.       print("lets subtract some numbers")
  27.       do_calc()
  28.       #operates with the input and print result
  29.       result = input1 - input2
  30.       print(input1," - " ,input2," = " ,result)
  31.   elif command == "multiply":
  32.       print("lets subtract some numbers")
  33.       do_calc()
  34.       #operates with the input and print result
  35.       result = input1 * input2
  36.       print(input1," * " ,input2," = " ,result)
  37.   elif command == "divide":
  38.       print("lets subtract some numbers")
  39.       do_calc()
  40.       #operates with the input and print result
  41.       result = input1 / input2
  42.       print(input1," / " ,input2," = " ,result)
  43.   elif command == "average":
  44.     how_many = input("How many numbers> ")
  45.     how_many = int(how_many)
  46.     total = 0
  47.     for number_count in range(how_many):
  48.         number = input("Enter number " + str(number_count) + "> ")
  49.         total = total + int(number)
  50.     result = total / how_many
  51.     print("the average = " + str(result))
  52.   elif command=="discount":
  53.     how_many = int(input("Which is the price > "))
  54.     discount = int(input("Which is the discount > "))
  55.     print ("The discount is ",discount/100*how_many," and the final prices is", how_many*(1-discount/100))
  56.   elif command=="meal":
  57.     print("Let's calculate the cost of meal")
  58.     how_many = int(input("How many you are > "))
  59.     discount = int(input("Which is the addition value > "))
  60.     print ("The price per person is",discount/how_many )
  61.   elif command=="bye":
  62.     finished=True
  63.   else:
  64.       print("sorry I dont understand")
  65.       #print polite error message in case nothing matchs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement