175k views
5 votes
For questions 2-4, consider the following code:

if (month ==9):
if (day > 15):
print ("Second half of the month")
else:
print ("First half of the month")
else:
print ("Not in September")
What is the output if month = 9 and day = 14?

User Marcopeg
by
5.0k points

2 Answers

12 votes

Answer:

e

Step-by-step explanation:

User Kenjiro
by
5.1k points
6 votes

Answer:

First half of the month

Step-by-step explanation:

Given

The above lines of code

Required

Determine the output if month = 9 and day = 14

The first if statement: if (month ==9): checks if month equals 9.

This statement is true, so the next statement is executed.

The next executable statement:

if (day > 15):

checks if day is greater than 15.

This statement is false, so the else statement is executed

else:

print ("First half of the month")

The above statement is executed and the string "First half of the month" is printed

User Tsundoku
by
4.9k points