Answer to Question #350229 in Python for eeee

Question #350229

Write an if-else statement that compares the age variable with the value 65. If age is greater than or equal to 65, add 1 to senior_citizens. Otherwise, add 1 to non_seniors.


1
Expert's answer
2022-06-13T08:26:21-0400
senior_citizens = 0
non_seniors = 0
while True:

    age = input('enter age, or "stop"')
    if age == 'stop':
        break
    else:
        age = int(age)

    if age > 65:
        senior_citizens+=1
    else:
        non_seniors+=1

    print(f'senior citizens:{senior_citizens} \n non seniors:{non_seniors}$)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS