Advertisement
pastebum

Discount feature

Aug 19th, 2019
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.61 KB | None | 0 0
  1. print ("Hi, I am Marvin, your personal bot.")
  2. users_name = input("What's your name? ")
  3. print ("Welcome " + users_name)
  4.  
  5. print("let's do some maths")
  6. operator = input ("Choose the operation you want to practise? ")
  7. if operator == ("add") or operator == ("plus"):
  8. # conditional sentence tha triggers "selection"
  9.     print("Please, enter the numbers you want to add:")
  10.     input1 = input("Number 1> ")
  11.     input2 = input("Number 2> ")
  12.     number1 = int(input1)
  13.     number2 = int(input2)
  14.     result = number1 + number2
  15.     output = str(result)
  16.     print (input1 + " + " + input2 + " = " + output)
  17. elif operator == ("subtract"):
  18.     print ("Please, enter the numbers you want to subtract")
  19.     subinput1 = input("Number 1> ")
  20.     subinput2 = input("Number 2> ")
  21.     subnumber1 = int(subinput1)
  22.     subnumber2 = int(subinput2)
  23.     subresult = subnumber1 - subnumber2
  24.     suboutput = str(subresult)
  25.     print (subinput1 + " - " + subinput2 + " = " + suboutput)
  26. elif operator == ("divide"):
  27.     print ("Please, enter the numbers you want to divide")
  28.     subinput1 = input("Number 1> ")
  29.     subinput2 = input("Number 2> ")
  30.     subnumber1 = int(subinput1)
  31.     subnumber2 = int(subinput2)
  32.     subresult = subnumber1 / subnumber2
  33.     suboutput = str(subresult)
  34.     print (subinput1 + " / " + subinput2 + " = " + suboutput)
  35. elif operator == ("multiply"):
  36.     print ("Please, enter the numbers you want to multiply")
  37.     subinput1 = input("Number 1> ")
  38.     subinput2 = input("Number 2> ")
  39.     subnumber1 = int(subinput1)
  40.     subnumber2 = int(subinput2)
  41.     subresult = subnumber1 * subnumber2
  42.     suboutput = str(subresult)
  43.     print (subinput1 + " x " + subinput2 + " = " + suboutput)
  44. elif operator == "average":
  45.     how_many = input("How many numbers?> ")
  46.     how_many = int(how_many)
  47.     total = 0
  48.     for number_count in range(how_many):
  49.         number = input("Enter number " + str(number_count) + "> ")
  50.         total = total + int(number)
  51.     result = total / how_many
  52.     print ("the average is " + str(result))  
  53.  
  54. elif operator == "discount" or operator == "total disccount":
  55.     count = 0
  56.     how_many = input("How many items of shopping do you have? ")
  57.     how_many = int(how_many)
  58.     for item_number in range (how_many):
  59.         item_price = input("Enter price of item " + str(item_number) + "> ")
  60.         count = count + int(item_price)
  61.     discount = input("What percentage is the discount?> ")
  62.     percentage = int(discount) / 100
  63.     result = count * percentage
  64.     print ("The total discount of your shop is " + str(result) + "£")
  65.    
  66.    
  67. else:
  68.     print("Sorry, I don't understand that command")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement