A person is eligible to be a US senator if they are at least
Solution
def congress( person_age, years_of_citizenship ):
eligible_for_us_senator = False;
eligible_for_us_representative = False;
if( person_age >= 25 and years_of_citizenship >= 7):
eligible_for_us_representative = True;
if( person_age >= 30 and years_of_citizenship >= 9):
eligible_for_us_senator = True;
if( eligible_for_us_senator and eligible_for_us_representative ):
return \"Eligible for the Senate and the House\";
elif( eligible_for_us_representative ):
return \"Eligible only for the House\";
else:
#if not eligible_for_us_representative, then also not eligible_for_us_senator
return \"Not eligible for Congress\";
def test():
ages = [65,35,35,28,24,45,18];
residency = [25,8,5,8,5,17,18];
for i in range(len(ages)):
result = congress( ages[i], residency[i] );
print \'Age \'+str(ages[i])+\' with \'+str(residency[i])+\' years of citizenship: \'+result;
test();
