Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

You must login to ask a question.

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Quizzma Latest Articles

4.4.6 Presidential Eligibility Extended CodeHS Answers

We thoroughly check each answer to a question to provide you with the most correct answers. Found a mistake? Tell us about it through the REPORT button at the bottom of the page. Ctrl+F (Cmd+F) will help you a lot when searching through such a large set of questions.

The most common answer is:

Age = int(input(“Age: “))
BornLocation = str(input(“Born in the U.S.?(Yes/No): “))
Year = input(“Years of Residency: “)
if((Age>=35) and (BornLocation==”Yes”) and (Year>=14)):
print(“You are eligible to run for president!”)
print(“You are not eligible to run for president.”)
print(“You are too young. You must be at least 35 years old.”)
print(“You must be born in the U.S. to run for president.”)
print(“You have not been a resident for long enough.”)

To ensure this program runs correctly and adheres to Python syntax, including using standard ASCII quotation marks and converting the “Years of Residency” input to an integer for proper comparison, here’s the revised version:

age = int(input("Age: "))
born_location = input("Born in the U.S.?(Yes/No): ").strip().capitalize()
years_of_residency = int(input("Years of Residency: "))

if age >= 35 and born_location == "Yes" and years_of_residency >= 14:
    print("You are eligible to run for president!")
    print("You are not eligible to run for president.")
    if age < 35:
        print("You are too young. You must be at least 35 years old.")
    if born_location == "No":
        print("You must be born in the U.S. to run for president.")
    if years_of_residency < 14:
        print("You have not been a resident for long enough.")

his code will:

  • Prompt the user to enter their age, whether they were born in the U.S., and their years of residency.
  • Check if the user meets the eligibility criteria to run for president: at least 35 years old, born in the U.S., and a resident for at least 14 years.
  • Print a message informing the user of their eligibility.
  • If the user does not meet one or more of the criteria, it will print specific messages explaining which criteria they did not meet.

Adjustments made include:

  • Converting BornLocation comparison to use .capitalize() to ensure the comparison works regardless of how the user inputs their answer, assuming they capitalize their “Yes” or “No” response.
  • Using .strip() to remove any leading or trailing spaces from the input.
  • Changing variable names to snake_case for Python convention (Age, BornLocation, Year to age, born_location, years_of_residency).

Was this helpful?

Quizzma Team

Quizzma Team

The Quizzma Team is a collective of experienced educators, subject matter experts, and content developers dedicated to providing accurate and high-quality educational resources. With a diverse range of expertise across various subjects, the team collaboratively reviews, creates, and publishes content to aid in learning and self-assessment.
Each piece of content undergoes a rigorous review process to ensure accuracy, relevance, and clarity. The Quizzma Team is committed to fostering a conducive learning environment for individuals and continually strives to provide reliable and valuable educational resources on a wide array of topics. Through collaborative effort and a shared passion for education, the Quizzma Team aims to contribute positively to the broader learning community.

Related Posts

Leave a comment