Write an if/else statement that compares the variable age with 65, adds 1 to the variable seniorCitizens if age is greater than or equal to 65, and adds 1 to the variable nonSeniors otherwise.

Respuesta :

if age >= 65:

seniorCitizens = seniorCitizens + 1

else:

nonSeniors = nonSeniors + 1

The  if/else statement that compares the variable age with 65, adds 1 to

the variable seniorCitizens if age is greater than or equal to 65, and adds 1

to the variable nonSeniors if  otherwise is written as follows:

seniorCitizens = 0

nonSeniors = 0  

age = int(input("input your age: "))

if age >= 65:

   seniorCitizens += 1

else:

   nonSeniors += 1

print(seniorCitizens)

print(nonSeniors)

The codes is written in python.

we declared two variables seniorCitizens  and nonSeniors as zero.

Ask the user for an age input

If the age is greater than or equals to 65 we add 1 to seniorCitizens

Else

we add 1 to nonSeniors

We print the seniorCitizens  and nonSeniors values.

The bolded values in the codes are python keywords.

learn more: https://brainly.com/question/12995751?referrer=searchResults

Ver imagen vintechnology
ACCESS MORE