LAB4_Python

This is the lab4 of EMT1111.in this lab i have to write a program that draws a grid using functions.The grid is composed only of three characters ‘+’,’-‘, and ‘|’. The top the middle and the last line of the grid are composed of something we will call beams, the string ‘+ – – – – ‘. The other lines are composed of something we will call a post. A post is the string ‘| ‘.
First i follower the instructions and copy the code :

def print_beam():

“””This function prints a beam”””
print ‘+ – – – -‘,

and i kept follow the steps and instruction .finally the grid came out.


source code :

Source Code
def print_beam():

print ‘+ – – – -‘,
def do_twice(f):

f()
f()
def do_four(f):
do_twice(f)
do_twice(f)

def print_beam():
print ‘+ – – – -‘,

def print_post():
print ‘| ‘,

def print_beams():
do_twice(print_beam)
print ‘+’

def print_posts():
do_twice(print_post)
print ‘|’

def print_row():
print_beams()
do_four(print_posts)

def print_grid():
do_twice(print_row)
print_beams()

print_grid()