duckstar001

Bot

May 14th, 2021 (edited)
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.34 KB | None | 0 0
  1. # Write your code here :-)
  2. print('I am ALICE your personal bot')
  3. user_name = input('What is your name: ')
  4. print('How can I help you today ' + user_name + '?')
  5. print()
  6. operation = input ('Would you like to add, subtract, divide, multiply or average some numbers today? ')
  7. print()
  8. # Checks what type of operation has been chosen.
  9. if operation == 'add' or operation == '+':
  10.     print('You have chosen to add the numbers')
  11.     number1 = int(input ('What is your first number?: '))
  12.     number2 = int(input ('What is your second number?: '))
  13.     result = number1 + number2
  14.     print('Your answer is ' + str(result))
  15. elif operation == 'subtract' or operation == '-':
  16.     print('You have chosen to add the subtract')
  17.     number1 = int(input ('What is your first number?: '))
  18.     number2 = int(input ('What is your second number?: '))
  19.     result = number1 - number2
  20.     print('Your answer is ' + str(result))
  21. elif operation == 'divide' or operation == '/':
  22.     print('You have chosen to divide the numbers')
  23.     number1 = int(input ('What is your first number?: '))
  24.     number2 = int(input ('What is your second number?: '))
  25.     result = number1/number2
  26.     print('Your answer is ' + str(result))
  27. elif operation == 'multiply' or operation == 'x' or operation == '*':
  28.     print('You have chosen to multiply the numbers')
  29.     number1 = int(input ('What is your first number?: '))
  30.     number2 = int(input ('What is your second number?: '))
  31.     result = number1 * number2
  32.     print('Your answer is ' + str(result))
  33. elif operation == 'average':
  34.     print('Let me average some number for you')
  35.     how_many = int(input('How many numbers do you want me to average: '))
  36.     #Takes an input and casts it to a interger / number
  37.     total = 0
  38.     for number_count in range(how_many):
  39.         number = input('Enter number ' + str(number_count) + ': ')
  40.         total = total + int(number)
  41.         # Asks for the number of each item, adding it to the total.
  42.     result = total / how_many
  43.     print('The average is ' + str(result))
  44.     # prints the result
  45. elif operation == 'shopping':
  46.     print('Let me take down your shopping list for you.')
  47.     shopping_list = []
  48.     #set up list
  49.     how_many = int(input('How many items do you want to add to your list? '))
  50.     #ask how many items to add
  51.     for item_number in range(how_many):
  52.         item = input('What item would you like to add to the list? ' )
  53.         shopping_list.append(item)
  54.     #add items one at a time to the list
  55.     print()
  56.     print('This is what is on your shopping list: ')
  57.     for item in shopping_list:
  58.         print(item)
  59.     print()
  60.     print('You have '+ str(len(shopping_list)) + ' items on your list')
  61.     #print out the list
  62. elif operation == 'discount':
  63.     print('Let me work out how much discount you get')
  64.     discount = int(input('What is the discount? '))
  65.     price = float(input('How much is the item? '))
  66.     #coverts to a float incase of decimals...
  67.     print('You want to know how much ' + str(discount) + '% discount off £' + str(price) +' is.')
  68.     print()    
  69.     reduced_price = round(price*(discount/100),2)
  70.     #rounds % discount to 2dp.
  71.     print('Your discount is £' + str(reduced_price) + '.')
  72.     print('Your item will now cost £' + str(round(price-reduced_price,2)) + '!')
  73.  
  74.  
  75.  
  76.  
  77. else:
  78.     print('I dont understand!')
  79. print()
  80. print('Till next time ' + user_name)
  81.  
Add Comment
Please, Sign In to add comment