Week 5 Warm Up

Create the following programs. Demo them to me when you complete them. For an example of how to print repeated characters on a single line, see printStars.py. For an example of functions calling other functions, see functionsCallingFunctions.py.

1) Create a program that takes an integer from the user. The program will have one function called "printLine" which will print a plus, followed by n-2 dashes, followed by a plus- all on the same line. Assume the user will always enter a valid integer of at least 2. For example:

>>>
Enter an int: 5
+---+
>>> ================================ RESTART ================================
>>>
Enter an int: 2
++

2) Create a program that takes an integer from the user. The program will have one function called "printSides" which will print a pipe character (|), followed by n-2 spaces, followed by a pipe- all on the same line. Assume the user will always enter a valid integer of at least 2. For example:

>>>
Enter an int: 5
|   |
>>> ================================ RESTART ================================
>>>
Enter an int: 2
||

2) Create a program that takes an integer from the user. The program will have three functions: "printLine" and "printSides" from the previous problem and a new function called "printBox". printBox must call printLine and printSides the appropriate amount of times to print a box of the size the user entered. Assume the user will always enter a valid integer of at least 2. For example:

>>>
Enter an int: 5
+---+
|   |
|   |
|   |
+---+
>>> ================================ RESTART ================================
>>>
Enter an int: 2
++
++
>>> ================================ RESTART ================================
>>>
Enter an int: 3
+-+
| |
+-+