Nov-02-2022, 12:34 PM
Hi,
I have been wondering for long that what's is the difference between the two definitions of "Tax =0"? One is "tax = 0" defined at the foremost; the second one is under the first if conditional statement. I am not sure whether definition under some specific conditional statement applies to the whole block.
Thanks a lot!
I have been wondering for long that what's is the difference between the two definitions of "Tax =0"? One is "tax = 0" defined at the foremost; the second one is under the first if conditional statement. I am not sure whether definition under some specific conditional statement applies to the whole block.
Thanks a lot!
value = int(input("Value of gift: ")) if value < 5000: tax = 0 elif value <= 25000: tax = 100 + (value - 5000) * 0.08 elif value <= 55000: tax = 1700 + (value - 25000) * 0.10 elif value <= 200000: tax = 4700 + (value - 55000) * 0.12 elif value <= 1000000: tax = 22100 + (value - 200000) * 0.15 else: tax = 142100 + (value - 1000000) * 0.17 if tax == 0: print("No tax!") else: print(f"Amount of tax: {tax} euros")and
value = int(input("Value of gift: ")) tax = 0 if value < 5000: tax == 0 elif value <= 25000: tax = 100 + (value - 5000) * 0.08 elif value <= 55000: tax = 1700 + (value - 25000) * 0.10 elif value <= 200000: tax = 4700 + (value - 55000) * 0.12 elif value <= 1000000: tax = 22100 + (value - 200000) * 0.15 else: tax = 142100 + (value - 1000000) * 0.17 if tax == 0: print("No tax!") else: print(f"Amount of tax: {tax} euros")