I’ve spent way too much time trying to find out the answer to this question below but I still can’t I think I’m having trouble where It’s talking about the age, but too difficult.

``````car_value = 10000
purchase_year = 2011
car_age = 8
driver_age = 23
electric = True
emissions_passed = True
``````

#You’re writing some code to determine how much it will cost

#Georgia’s tag renewal policies are unnecessarily
#complicated. I’ve simplified them to make this problem even
#doable. They are:

# - Everyone pays \$20.
# - If you purchased your car before 2013 (in 2012 or earlier),
# you also pay 1% of its current value in additional tax.
# - If the car is electric, you pay an additional \$200 fee.
# (This is real.)
# - To renew, you must have passed an annual emissions check,
# unless your car is electric, or if you’re 65 or over and
# the car’s age is 10 years or older.

#Your code should print one of two messages. If the person
#needs to pass an emissions test in order to renew their tag,
#it should print, “You must pass an emissions test first.”
#This would be the message to print if emissions_passed is
#False and if they are not eligible for either exemption
#mentioned above.

#If the person is eligible to renew their tag, the code should
#print: “Your renewal fee is \$__.”, where __ is the renewal
#cost. Round the renewal fee to the nearest integer. This will
#be \$20, plus \$200 if the car is electric, plus 1% of car_value
#if the purchase_year is less than or equal to 2012.

``````car_value_percentage = int(car_value * 0.01)

if emissions_passed == True:
if purchase_year <= 2012:
if electric:
print("Your renewal fee is \$" + str(200 + 20 + car_value_percentage) + ".")
elif not electric:
print("Your renewal fee is \$" + str(20 + car_value_percentage) + ".")
elif purchase_year >= 2012 and electric:
print("Your renewal fee is \$" + str(20 + 200) + ".")
elif purchase_year >= 2012 and not electric:
print("Your renewal fee is \$" + str(20) + ".")
if emissions_passed == False and (not electric and car_age >= 10 or driver_age >= 65):
print("You must pass an emissions test first.")
else:
if emissions_passed == False:
if purchase_year <= 2012:
if electric:
print("Your renewal fee is \$" + str(200 + 20 + car_value_percentage) + ".")
elif not electric:
print("Your renewal fee is \$" + str(20 + car_value_percentage) + ".")
elif purchase_year >= 2012 and electric:
print("Your renewal fee is \$" + str(20 + 200) + ".")
elif purchase_year >= 2012 and not electric:
print("Your renewal fee is \$" + str(20) + ".")
``````

You’re pretty close, but the code is harder to read in my opinion because `emission_passed` is being checked first.

I would suggest trying this to simplify.

Instead of starting with checks on `emissions_passed`:

``````if emissions_passed == True:
``````

Try instead checking `electric` and `age` first:

``````if electric or age_check:
# is electric or agecheck
# - unless your car is electric
#- or if you’re 65 or over
# - and the car’s age is 10 years or older.
else:
# it requires emissions check
if emission_passed:
# not electric and passed
else:
# not electric and not passed

# and then apply the fees over the top
base_fee = 20
# - If you purchased your car before 2013 (in 2012 or earlier),
base_fee * 1.01
# you also pay 1% of its current value in additional tax.
# - If the car is electric, you pay an additional \$200 fee.
base_fee + 200

if can_renew:
pass
else:
pass
``````

And then going with what you have:

1 Like

i’m a 15yo programmer, i solved it this way, altough this code only works with integers and not decimals, you can try to do that yourself if u need

``````car_value = int(input("car value: "))
purchase_year = int(input("purchase year: "))
car_age = int(input("car age: "))
driver_age = int(input("driver age: "))
electric = bool(int(input("is electric?(1 for yes, 0 for no): ")))
emissions_passed = True
renewal_fee = 20

if not electric:
if driver_age >= 65:
if not car_age >= 10:
emissions_passed = bool(int(input("emissions check passed?(1 for yes, 0 for no): ")))
else:
emissions_passed = bool(int(input("emissions check passed?(1 for yes, 0 for no): ")))

if purchase_year <= 2012:
renewal_fee += (car_value / 100)

if electric:
renewal_fee += 200

if emissions_passed: