Sep-24-2016, 02:53 PM
I am new to programming. learning python by watching online videos and doing exercises so i guess i qualify as a student.
my exercise is this:
Calculate the total to charge for an order from an online store in Canada
• Ask user what country they are from and their order total
• If the user is from Canada, ask which province
• If the order is from outside Canada do not charge any taxes
• If the order was placed in Canada calculate tax based on the province
– Alberta charge .05% General sales Tax (GST)
– Ontario, New Brunswick, Nova Scotia charge .13% Harmonized sales tax
– All other provinces charge .06% provincial sales tax + .05% GST tax
• Tell the user the total with taxes for their order
Here is the code i wrote to solve the exercise:
:huh: :huh: :huh: :huh: :s :s :s
my exercise is this:
Calculate the total to charge for an order from an online store in Canada
• Ask user what country they are from and their order total
• If the user is from Canada, ask which province
• If the order is from outside Canada do not charge any taxes
• If the order was placed in Canada calculate tax based on the province
– Alberta charge .05% General sales Tax (GST)
– Ontario, New Brunswick, Nova Scotia charge .13% Harmonized sales tax
– All other provinces charge .06% provincial sales tax + .05% GST tax
• Tell the user the total with taxes for their order
Here is the code i wrote to solve the exercise:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
country = "" province = "" gst = 0.5 hst = 0.13 #0.6%taxes for other provinces otp = 0.6 tax = 0 tax1 = 0 tax2 = 0 orderTotal = 0 country = input ( 'what country are you from?' ) if country.upper() = = 'CANADA' : province = input ( "what province of CANADA are you from?:" ) if province.upper() = = 'ALBERTA' : orderTotal = input ( 'what is your order total?:' ) tax = (orderTotal * gst) orderTotal = (orderTotal + tax) print ( 'your General sales tax based on your chosen province of %s is %.2f and total order is %.2f' % (province,tax,orderTotal)) if province.upper() = = 'ONTARIO' or province.upper() = = 'NEW BRUNSWICK' or province.upper() = = 'NOVA SCOTIA' : orderTotal = ( 'what is your order total?:' ) tax = (orderTotal * hst) orderTotal = (ordertotal + tax) print ( 'your harmonized sales tax based on your chosen province of %s is %.2f and total order is %.2f' % (province,tax,orderTotal)) elif country.upper = = 'CANADA' and (province.upper()! = 'ALBERTA' or province.upper()! = 'ONTARIO' or province.upper()! = 'NEW BRUNSWICK' or province.upper()! = 'NOVA SCOTIA' ): province = input ( 'what province of CANADA are you from?: ' ) orderTotal = ( 'what is your order total?:' ) tax1 = (orderTotal * otp) tax2 = (orderTotal * hst) orderTotal = (orderTotal + tax1 + tax2) print ( 'your provincial sales tax %.2f and GST tax %.2f based on your chosen province of %s is %.2f and total order is %.2f' % (tax1,tax2,province,tax,orderTotal)) else : orderTotal = ( 'what is your order total?: ' ) #orderTotal=float(orderTotal) print ( 'your order total is $%.2f' % (orderTotal)) Please i need assistance, not only to find out but to understand what exactly i am doing wrong. I have gone through several variations and while some code compile ,they fail the testing phase when i run it. hope to hear from somebody soon Thank you so much for your help . |