This program is written to draw a grid that contain beams, posts, and columns. The function is mainly used in this program. There are three main function that can draw beam, post, and column. By repeating these function, we can draw a grid.
Source code:
def do_twice(f):
“””This function invokes twice the function passed as parameter”””
f()
f()
def do_three(f):
“””This function invokes twice the function passed as parameter”””
f()
f()
f()
def do_four(f):
“””This function invokes four times the function passes as parameter. It makes
use of the do_twice function.”””
do_twice(f)
do_twice(f)
def print_beam():
“””This function prints a beam”””
print (‘+ – – – – ‘,end=””)
def print_post():
“””This function prints a post”””
print (‘| ‘,end=””)
def print_beams():
print_beam()
print_beam()
print_beam()
print(‘+’)
def print_posts():
print_post()
print_post()
print_post()
print(‘|’)
def print_row():
“””This funcion print a row of grid”””
print_beams()
print_posts()
print_posts()
print_posts()
print_posts()
def print_grid():
“””This function prints the grid using do_twice”””
do_three(print_row)
print_beams()
print_grid()