Предмет: Информатика,
автор: abdukalilovasaikal
Write a program that reports whether or not someone is eligible to run for president in the U.S. You should do the following in your program:
Ask the user for their age, and store it in a variable
Ask the user if they are a citizen of the U.S.
Ask the user how long they’ve been a resident in the U.S.
Use an if/else statement with the proper comparison operator to print You are eligible to run for president! if they have the following credentials:
They are at least 35 years old
They were born in the U.S.
They have been a resident for at least 14 years
An example run of your program might look like this:
Age: 19
Born in the U.S.? (Yes/No): Yes
Years of Residency: 19
You are not eligible to run for president.
… or like this:
Age: 40
Born in the U.S.? (Yes/No): Yes
Years of Residency: 20
You are eligible to run for president!
Note:
Remember that capitalization is very important! Make sure to check if the user replied ‘Yes’ or ‘No’, not ‘yes’ or ‘no’. You will not pass the autograder if your capitalization is off!
Ответы
Автор ответа:
0
Ответ:
Here's a Python program that asks the user for their age, citizenship status, and length of residency in the U.S., and determines if they are eligible to run for president:
# ask user for their age
age = int(input("Age: "))
# ask user if they are a citizen of the U.S.
citizen = input("Born in the U.S.? (Yes/No): ")
# ask user how long they've been a resident in the U.S.
residency = int(input("Years of Residency: "))
# determine if they are eligible to run for president
if age >= 35 and citizen == "Yes" and residency >= 14:
print("You are eligible to run for president!")
else:
print("You are not eligible to run for president.")
Похожие вопросы
Предмет: Немецкий язык,
автор: alinacrooooo
Предмет: Українська мова,
автор: afanasevb052
Предмет: Физика,
автор: ismartsdn10432
Предмет: Русский язык,
автор: orehovaleksej89
Предмет: Химия,
автор: pechenkaplay3