2nd Semester Intro to Computer Science

Do Now 4.03

Type in your Console

def print_6_stars():
my_string = ''
for i in range(0, 6):
    my_string += ' *'
print(my_string)

In your Notebook

  1. Write down what the output of the function print_6_stars is.
  2. Write a function print_star_square that calls print_6_stars in a loop to produce the following output.

     >>>python3 print_stars.py
     * * * * * *
     * * * * * *
     * * * * * *
     * * * * * *
     * * * * * *
     * * * * * *
    
  3. Rewrite the function print_star_square without using print_6_stars.
    • Note that there are two ways to get the above output, so just try doing both!

Edit this page Report an issue