livepython.net

131. Python Program to Draw a Box Using Functions

MediumFunctions

Overview

Split a drawing into two small named jobs, and call each one where it's needed.

Problem Statement

Write two functions:

  • draw_edge() prints +--------+ (a plus, 8 dashes, a plus).
  • draw_side() prints | | (a bar, 8 spaces, a bar).

Then read the height of the box (a whole number) and draw the box: one edge, then that many sides, then another edge. For example, for 3:

+--------+
|        |
|        |
|        |
+--------+

Use input() with no prompt text: the tests type the input for you, and a prompt would end up in your output.

Input

One whole number, 1 or more. Example:

3

Output

The box shown above. Spaces count, so check there are exactly 8 between the bars.

The tests try 3 different inputs.

Learn this firstChapter 15 · Python Functions: Define and Call Your Own
solution.py
# write your code here

EXPECTED OUTPUT

1+--------+
2| |
3| |
4| |
5+--------+

YOUR OUTPUT

Press Run to see your output here. Lines are compared with the expected output.