Sub programs - watch the videos first & take some notes
|
|
Now take the quiz
Now complete the program below
Partially completed code
Copy and paste the code below into a repl or other Python IDE. Instructions are written as comments. Complete the program remembering to add comments of your own.
# a program to calculate the area of a room
#--------------------------------
# Library modules
#--------------------------------
# modules like time, random, math are imported here
#--------------------------------
# global variables
#--------------------------------
#--------------------------------
# Sub programs
#--------------------------------
# add comments to explain the sub program below
def room_area():
length = float(input('Enter the length of the room: '))
width = float(input('Enter the width of the room: '))
return length * width
#--------------------------------
# Main program
#--------------------------------
area = # complete this line by calling the function. The returned value will be stored in the variable area.
print('The area of the room is '+ # complete this line so the area of the room is displayed.
#--------------------------------
# Library modules
#--------------------------------
# modules like time, random, math are imported here
#--------------------------------
# global variables
#--------------------------------
#--------------------------------
# Sub programs
#--------------------------------
# add comments to explain the sub program below
def room_area():
length = float(input('Enter the length of the room: '))
width = float(input('Enter the width of the room: '))
return length * width
#--------------------------------
# Main program
#--------------------------------
area = # complete this line by calling the function. The returned value will be stored in the variable area.
print('The area of the room is '+ # complete this line so the area of the room is displayed.
Submit your finished code & notes
Remember that if you need any help you just need to send an email.