Quiz Question 1 of 5
In a given program, the variable rooms
is initialized to 1. The following code is executed:
if attendees >= 100:
rooms += 3
if attendees <= 200:
rooms += 7
elif attendees <= 400:
rooms += 14
If the number of attendees is 150, what is the final value of rooms
, and what does this suggest about the logic of the code?
Choose the correct answer below:
-
A
18; The logic allows both the first and second if statements to execute, but not the elif.
-
B
15; The program incorrectly considers the elif branch along with the first if statement.
-
C
11; The logic is correct, as only the first two conditions should execute.
-
D
7; Only the second if statement executes, due to incorrect logical branching.