CSc 250 Lab 3

In this lab, we’ll work through some problems that emphasize while-loops and expressions.

Problem 1

Create a new program called box.py. This program will print out a box that is 5 characters wide, and N characters tall (where N is a input value chosen by the user). The user should also be able to specify the character that the box will be made out of. Do not use any string multiplication! Below are two example runs, to give you an idea of the ideal behavior:
What character to use for the box? X
Box height: 3
The box is ...

XXXXX
XXXXX
XXXXX
What character to use for the box? !
Box height: 5
The box is ...

!!!!!
!!!!!
!!!!!
!!!!!
!!!!!

Problem 2

Create a file named box-2.py, and copy your code over from box.py. Change it so that the box can be made out of two types of characters. The box will be printed out with these two characters on every-other line. For example:
First box character: A
Second box character: B
Box height: 4
The box is ...

AAAAA
BBBBB
AAAAA
BBBBB
First box character: -
Second box character: |
Box height: 5
The box is ...

-----
|||||
-----
|||||
-----

Problem 3

Create a file named box-3.py, and copy your code over from box-2.py. Change it so that the box width can also be specified. Again, do NOT use any string multiplication. You might need to put a while-loop inside of another while-loop. For example:
First box character: A
Second box character: B
Box width: 2
Box height: 4
The box is ...

AA
BB
AA
BB
First box character: -
Second box character: |
Box width: 7
Box height: 5
The box is ...

-------
|||||||
-------
|||||||
-------

Problem 4

Write a new program named tree.py. this problem is basically the same one that we started working on at the end of class on Monday. This program will print out trees of a custom body height and trunk height (which will both be user inputs). so that the box width can also be specified. Again, do NOT use any string multiplication. You might need to put a while-loop inside of another while-loop. For example, a body height of 7 and a trunk height of 1 will produce:
      *
     ***
    *****
   *******
  *********
 ***********
*************
      X
But a body height of 4 and a trunk height of 2 will produce:
   *
  ***
 *****
*******
   X
   X
Use while-loops for printing out the rows!

You must turn in at least 2 of the 4 problems on D2L to get credit for this.

No solutions will be posted