I’m working on a project for school (Python 2.7.10) and it basically told us what to do. All we’re doing is comparing “age” and length of “citizenship” to see if someone is eligible for both the Senate and the House. The House only. Or completely ineligible.
When I run my conditional statement the only thing that comes back is “You are eligible for both the Senate and the House”. This comes back no matter what numbers I put in. And I cannot seem to figure out why?
age = str(raw_input("Enter age: "))
citizen = str(raw_input("Enter number of years as a US citizen: "))
if age >= 30 and citizen >= 9:
print "You are eligible for both the Senate and the House "
elif age >= 25 and citizen >= 7:
print "You are only eligible for the House. "
else:
print “You are ineligible to serve.”
These are ALL of the instructions that I followed
In the United States, a citizen is eligible to be a US Senator who is at least 30 years old and has been a US citizen for at least 9 years. Also, a citizen is eligible to be a US Representative who is at least 25 years old and has been a US citizen for at least 7 years.
Write a script to obtain age and length of citizenship from the user and return to the screen via a print statement if the user is eligible to for the US Senate, the US House of Representatives, both or neither.
Create your script (congress.py) so it obtains age and length of citizenship from the user - the age and years of citizenship should not be assigned in the script, but rather use raw_input() to request the information from the user.
The script must return to the screen the correct response based on the age and citizenship years the user enters. One of the following three statement must be correctly printed to screen by the script:
You are eligible for both the House and Senate
You are only eligible for the House
You are ineligible to serve
In addition to the user input for the Age and Citizen values, you must utilize a single Conditional Statement to compare BOTH values and return the correct statement. Using this information, complete the script below and submit via FSO:
STUDENT NAME HERE
Python version 2.7.10
Congress Age Checker
raw_input() allows the user to enter a value for the variable ‘age’
str() tells python to treat the value as a string
"Enter Age: " is the prompt that will appear to the user when the script is executed
age = str(raw_input("Enter Age: "))
Using the above as a guide, complete the following line so that
"Enter Number of years as a US Citizen: " will appear when the script is executed
citizen =
Conditional Statement
Using the variables ‘age’ & ‘citizen’, construct a conditional statement that will
check to see is the user is eligible for the Senate, House of Representatives, both or neither.
To help you get started the first condition has been provided for you
if ___ >= 30 and citizen >= 9:
print "You are eligible for the Senate and the House "
____ age >= 25 and citizen >= __:
print “You are eligible for the House of Representatives.”
else:
print “You are ineligible to serve.”