Skip to content

Latest commit

 

History

History
98 lines (79 loc) · 1.77 KB

File metadata and controls

98 lines (79 loc) · 1.77 KB

Lab 4.03 - Nested For Loops

Instructions

In this lab we will be drawing images using nested for loops.

For each of the following problems, you will write a function that will draw the desired output. You may use an extra function if you find it helpful.

  1. Write a function, draw_7, to draw the 7x7 square (shown below)
    * * * * * * *
    * * * * * * *
    * * * * * * *
    * * * * * * *
    * * * * * * *
    * * * * * * *
    * * * * * * *
  1. Write a function stars_and_stripes, that will draw a 3 sets of rows. 1st a row of 7 stars followed by a row of 7 dashes (shown below)
    * * * * * * *
    - - - - - - -
    * * * * * * *
    - - - - - - -
    * * * * * * *
    - - - - - - -
  1. Write a function, increasing_triangle that will print out the following:
    1
    1 2
    1 2 3
    1 2 3 4
    1 2 3 4 5
    1 2 3 4 5 6
    1 2 3 4 5 6 7
  1. Write a function, vertical_stars_and_stripes that will print out the following:
    - * - * - * -
    - * - * - * -
    - * - * - * -
    - * - * - * -
    - * - * - * -
    - * - * - * -
    - * - * - * -

Bonus

Use a function to create your own pattern or drawing. Some possible pattern ideas:

  1. Write a function that will print a border around a 7x7 square (shown below)
    * * * * * * * *
    * - - - - - - *
    * - - - - - - *
    * - - - - - - *
    * - - - - - - *
    * - - - - - - *
    * - - - - - - *
    * - - - - - - *
    * * * * * * * *
  1. Write a function that will print the following balanced_triangle.
    1
    1 2
    1 2 3
    1 2 3 4
    1 2 3 4 5
    1 2 3 4 5 6
    1 2 3 4 5 6 7
    1 2 3 4 5 6
    1 2 3 4 5
    1 2 3 4
    1 2 3
    1 2
    1
  1. Write a function that will print the following triangle.
       *
      ***
     *****