Solution: Guess My Number
answer = 35
guess = 30 # this is just a sample answer and guess
if guess < answer:
result = "Oops! Your guess was too low."
elif guess > answer:
result = "Oops! Your guess was too high."
elif guess==answer:
result = "Nice! Your guess matched the answer!"
print(result)
Output
Oops! Your guess was too low.
Solution: Tax Purchase
state = 'CA'
purchase_amount = 20.00 # a sample state and purchase amount
if state == 'CA':
tax_amount = .075
total_cost = purchase_amount*(1+tax_amount)
result = "Since you're from {}, your total cost is {}.".format(state, total_cost)
elif state == 'MN':
tax_amount = .095
total_cost = purchase_amount*(1+tax_amount)
result = "Since you're from {}, your total cost is {}.".format(state, total_cost)
elif state == 'NY':
tax_amount = .089
total_cost = purchase_amount*(1+tax_amount)
result = "Since you're from {}, your total cost is {}.".format(state, total_cost)
print(result)
Output
Since you're from CA, your total cost is 21.5.