CSc 110 - Short PA - Bars

In this short PA, you should write three separate program to print out bars of hash-tags (#) in various ways. Completing this PA should give you some confidence/preparation to start working on the regular PA for this week, so work on this first! You should name the programs rab.py, cab.py, and lab.py (Acronyms for Right-, Center-, and Left- aligned bars). Each of the three program should accept one input value, a string of digit characters, 0-9. The program should not accept any other characters (such as letters, commas, periods, etc) in the input. The behaviour of each of the programs is described below.

Enter bars string:
2378945
+---------+
|##       |
|###      |
|#######  |
|######## |
|#########|
|####     |
|#####    |
+---------+
Enter bars string:
71727
+---------+
|#######  |
|#        |
|#######  |
|##       |
|#######  |
+---------+

Left-aligned bars (lab.py)

lab.py Should accept a string of digits as input. The program should iterate through each of the digits in the string and convert the individual digits to integers. For each of the numbers, the program should print out the corresponding number of horizontal bars of # characters, within a nicely-formatted box. The box should always be 11 characters wide in total, but the height may vary based on the length of the input string. Two example runs of the program are shown on the left.

Enter bars string:
2378945
+---------+
|       ##|
|      ###|
|  #######|
| ########|
|#########|
|     ####|
|    #####|
+---------+
Enter bars string:
71727
+---------+
|  #######|
|        #|
|  #######|
|       ##|
|  #######|
+---------+

Right-aligned bars (rab.py)

rab.py should accept the same type of input as lab.py. It should print out a box with the bars right-aligned, instead of left-aligned. Two example runs of the program are shown on the left.

Enter bar string:
13155371
+------------------+
|        ####      |
|        ######    |
|    ########      |
|  ########        |
+------------------+
Enter bar string:
355399271122
+------------------+
|      ########    |
|    ########      |
|##################|
|       #########  |
|        ##        |
|       ####       |
+------------------+

Center-aligned bars (cab.py)

cab.py Should accept a string of digits as input. However, the way that the program uses the numbers should differ slightly from lab.py and rab.py. In cab.py, each pair of numbers is used to produce the output on a given row. the bars should “start” from the center of the 20-character-wide box, and the input string specifies how much they should jut-out to the left and to the right. For instance, look at the first example in the table to the right. In the first row, the bar has three # to the left of center, and five # characters to the right of center. This is specified by the 35 in the input string. The third and fourth characters, 53, specifies 5 to the left and three to the right.

Commenting and Style

You should follow all of the code style and structure rules describes in the style guide, available from the class website.

Due Date

This PA is due on Saturday, September 26th at 7pm. Turn in the program via Gradescope. You should make sure that all of the test cases pass before you turn it in. You can still submit without all of the cases passing, but that is not preferable.