SHARE
TWEET

Untitled

a guest Aug 19th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Bot to answer user questions doing basic maths
  2. deviceName = "Bot"
  3. print("Hello, I am your personal " + deviceName)
  4. users_name = input("What is your your name? ")
  5. print("Hello " + users_name +", it good to meet you.")
  6. print("I can do calculation for you to add, subtract, divide, multiple and average values")
  7.  
  8. print("Choose your operation from the list below")
  9. command = input("type: \n1 to add\n2 to subtract\n3 to multiple\n4 to divide\n5 to average\n6 to shoplist_calculator \n>_ ")
  10.  
  11. if command == "1" or command == "add":
  12.     print("I am going to add the numbers together")
  13.     num1 = int(input("Enter a number >_ "))
  14.     num2 = int(input("Enter another number>_ "))
  15.     add = num1 + num2
  16.     result_add = str(add)
  17.     print("The total of the two numbers is > " + result_add)
  18. elif command == "2" or command == "subtract":
  19.     print("I am going to subtract the second number from first number")
  20.     num1 = int(input("Enter the first number >_ "))
  21.     num2 = int(input("Enter the second number>_ "))
  22.     subt = num1 - num2
  23.     result_sub = str(subt)
  24.     print("Subtracting", num2, " from ", num1, " gives a difference of >_ " + result_sub)
  25. elif command == "3" or command == "multiply":
  26.     print("I am going to multiply the two numbers")
  27.     num1 = int(input("Enter the first number >_ "))
  28.     num2 = int(input("Enter the second number>_ "))
  29.     mult = num1 * num2
  30.     result_mult = str(mult)
  31.     print("The product of ", num1, " and ", num2, " gives >_ " + result_mult)
  32. elif command == "4" or command == "divide":
  33.     print("I am going to divide your two numbers")
  34.     num1 = int(input("Enter the numerator number >_ "))
  35.     num2 = int(input("Enter the denominator number>_ "))
  36.     div = num1 / num2
  37.     result_div = str(div)
  38.     print("The quotient from dividing ", num1, " by ", num2, " gives >_ " + result_div)
  39.    
  40. elif command == "5" or command == "average":
  41.     total = 0
  42.     count = 0
  43.     numNumbers = int(input("How many numbers do you want to average > "))
  44.     for count in range(numNumbers):
  45.         numEntered = input("Enter a number to include in your average " +str(count + 1) + "> ")
  46.         total = total + int(numEntered)
  47.     average = total / numNumbers
  48.     print("The average of the  ", numNumbers, " numbers entered is " + str(average))
  49. elif command == "6" or command == "shoplist_calculator":
  50.     print("\nI will take a list of shopping items, their price and calculate a a running total for you")
  51.     shopping = []
  52.     count = 0
  53.     total =0.0
  54.     count = int(input("How many items do you want to include in your shopping list > "))
  55.     for item in range(count):
  56.         listitem = input("\nEnter item for your shopping list item number " +str(item + 1) + "> ")
  57.         shopping.append(listitem)
  58.         itemcost = input("Enter the cost of the item " +str(item + 1) + "> ")
  59.         total = total + float(itemcost)  #could place price in list so could output next to item
  60.     print("\nto confirm, this is your list:")  # new line to separate list
  61.     for item in shopping:  #now to print the list
  62.         print ("\t\t\t\t\t",item)    #adding tabs to indent the list of items
  63.     total_items=len(shopping)
  64.     print ("\nYou have " + str(total_items) + " items in your shopping list")
  65.     print("and the total cost of the items entered is £ " + str(total))
  66.    
  67. else:
  68.     print("Sorry I don't understand")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top