Advertisement
xavicano

Untitled

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