asked 218k views
1 vote
A program reads as follows:

age < 2:
if
print ("free admission")
elif 2 age < 12:
print ("children's admission is $5")
elif 12 çage 3 22:
print ("student admission is $8")
elif age > 22:
print ("general admission is $10")
If the age of the ticket buyer is entered as 13, how many steps would the program run through be​

2 Answers

1 vote

Answer:

It would take 3 steps before executing

Explanation:

answered
User Jan Petr
by
8.2k points
5 votes

The program goes through the following steps when the input is 13

step 1) check to see if the age is less than 2. It is not, so we move on

step 2) check to see if the age is 2 to less than 12. It is not, so we move on

step 3) check to see if the age is 12 to less than 22. We are in the right range, so we execute the print statement "student admission is $8"

After this the program is done. It doesn't check to see if the age is greater than 22 (that only would apply if the other if statements were false).

So we have four steps. The first three are checking those "if" statements mentioned. The fourth statement is executing the print output to show the price.

answered
User Ajitej Kaushik
by
7.6k points
Welcome to Qamnty — a place to ask, share, and grow together. Join our community and get real answers from real people.