Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print ("Hi, I am Marvin, your personal bot.")
- users_name = input("What's your name? ")
- print ("Welcome " + users_name)
- print("let's do some maths")
- operator = input ("Choose the operation you want to practise? ")
- if operator == ("add") or operator == ("plus"):
- # conditional sentence tha triggers "selection"
- print("Please, enter the numbers you want to add:")
- input1 = input("Number 1> ")
- input2 = input("Number 2> ")
- number1 = int(input1)
- number2 = int(input2)
- result = number1 + number2
- output = str(result)
- print (input1 + " + " + input2 + " = " + output)
- elif operator == ("subtract"):
- print ("Please, enter the numbers you want to subtract")
- subinput1 = input("Number 1> ")
- subinput2 = input("Number 2> ")
- subnumber1 = int(subinput1)
- subnumber2 = int(subinput2)
- subresult = subnumber1 - subnumber2
- suboutput = str(subresult)
- print (subinput1 + " - " + subinput2 + " = " + suboutput)
- elif operator == ("divide"):
- print ("Please, enter the numbers you want to divide")
- subinput1 = input("Number 1> ")
- subinput2 = input("Number 2> ")
- subnumber1 = int(subinput1)
- subnumber2 = int(subinput2)
- subresult = subnumber1 / subnumber2
- suboutput = str(subresult)
- print (subinput1 + " / " + subinput2 + " = " + suboutput)
- elif operator == ("multiply"):
- print ("Please, enter the numbers you want to multiply")
- subinput1 = input("Number 1> ")
- subinput2 = input("Number 2> ")
- subnumber1 = int(subinput1)
- subnumber2 = int(subinput2)
- subresult = subnumber1 * subnumber2
- suboutput = str(subresult)
- print (subinput1 + " x " + subinput2 + " = " + suboutput)
- elif operator == "average":
- how_many = input("How many numbers?> ")
- how_many = int(how_many)
- total = 0
- for number_count in range(how_many):
- number = input("Enter number " + str(number_count) + "> ")
- total = total + int(number)
- result = total / how_many
- print ("the average is " + str(result))
- elif operator == "discount" or operator == "total disccount":
- count = 0
- how_many = input("How many items of shopping do you have? ")
- how_many = int(how_many)
- for item_number in range (how_many):
- item_price = input("Enter price of item " + str(item_number) + "> ")
- count = count + int(item_price)
- discount = input("What percentage is the discount?> ")
- percentage = int(discount) / 100
- result = count * percentage
- print ("The total discount of your shop is " + str(result) + "£")
- else:
- print("Sorry, I don't understand that command")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement