Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Chap.3 Functions Hw
- print('#3.1')
- #3.1
- def right_justify(s):
- a = len(s)
- b = ' '
- c = 70 - a
- d = b*c+s
- print(len(d))
- print(d)
- right_justify('monty')
- print('\n')
- print('#3.2.1')
- #3.2.1
- def do_twice(f):
- f()
- f()
- def print_spam():
- print('spam')
- do_twice(print_spam)
- print('\n')
- print('#3.2.2-5')
- #3.2.2-5
- def do_twice(f,s):
- f(s)
- f(s)
- def print_twice(s):
- print(s)
- print(s)
- def do_four(f,s):
- do_twice(f,s)
- do_twice(f,s)
- do_twice(print_twice, 'spam1')
- do_four(print_twice, 'spam2')
- print('\n')
- print('#3.3')
- #3.3
- def do_twice(f):
- f()
- f()
- def do_four(f):
- do_twice(f)
- do_twice(f)
- def print_beam():
- print('+ - - - -', end = ' ')
- def print_post():
- print('| ', end = ' ')
- 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()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement