if
It's time to take a closer look around in your house.
Two variables are defined in the sample code: room
, a string that tells you which room of the house we're looking at, and area
, the area of that room.
This exercise is part of the course
Intermediate Python
Exercise instructions
- Examine the
if
statement that prints out"looking around in the kitchen."
ifroom
equals"kit"
. - Write another
if
statement that prints out "big place!" ifarea
is greater than 15.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Define variables
room = "kit"
area = 14.0
# if statement for room
if room == "kit" :
print("looking around in the kitchen.")
# if statement for area