Lab 3, Part 2: Happy Owls

Let's practice some more with functions, parameters, and the bigger picture idea of abstraction.

Open /lab03/drawOwls.py and examine the given strings:

empty = '          '
lineA = '     {o,o}'
lineB = '     /)_) '
lineC = '      " " '

These strings, if printed, produce a simple ASCII art owl.

Owl x 1

Partner A

In the drawOwls.py file, write a function called owl that will print a single owl using the given strings.

>>> owl()

     {o,o}
     /)_)
      " "

Note: None of the following functions can use these strings again except for owlRow.

Owl x 2

Partner B

Write a second function called owlPair that prints two owls in a column like this:

>>> owlPair()

     {o,o}
     /)_)
      " "

     {o,o}
     /)_)
      " "

Owl x 4

Write a third function called owlQuad that prints four owls in a column like this:

>>> owlQuad()

     {o,o}
     /)_)
      " "

     {o,o}
     /)_)
      " "

     {o,o}
     /)_)
      " "

     {o,o}
     /)_)
      " "

Owls in rows

Partner A

Write a fourth function called owlRow that takes one parameter (n) and prints the specified number of owls in a row.

In this function, you can (and will need to) use the predefined strings (eg empty, lineA, lineB, lineC) again.

Example 1.

>>> owlRow(2)

     {o,o}     {o,o}
     /)_)      /)_)
      " "       " "

Example 2.

>>> owlRow(3)

     {o,o}     {o,o}     {o,o}
     /)_)      /)_)      /)_)
      " "       " "       " "

Example 3.

>>> owlRow(5)

     {o,o}     {o,o}     {o,o}     {o,o}     {o,o}
     /)_)      /)_)      /)_)      /)_)      /)_)
      " "       " "       " "       " "       " "

Table of Contents