n this lab you will gain some practice with lists and tuples.

Docstring Guide

Problem: ASCII Art Roses

Long ago, before computers could display high resolution graphics on 4K monitors with 300 dpi pixel density and churn out stunning real-time 3D graphics at 60 frames per second, many people spent a lot of time making art on computers out of text using the ASCII character set.

Like this:

.........................................
...####...####....###...##..##...####....
..##.....##........##...##..##..##..##...
..##......###......##...######...#####...
..##........##.....##.......##......##...
...####..####.....####......##....###....
.........................................

You are going to write a program to output five ASCII art roses. Like this:

     @-->---->---
      @----->->--
@----->------->--
  @->->----------
           @->->-    

Each rose starts with an @ followed by a section of dashes - before the first thorn >, followed by a second section of dashes to a second thorn, followed by a final section of dashes -.

For your first pass at this algorithm, you should have five variables: rose1, rose2, rose3, rose4, and rose5. Each variable should refer to a tuple with 3 integers denoting the number of dashes ('-') in each of the rose’s sections. For example, the first rose in the figure above has two dashes in the first section, four dashes in the second section, and three dashes in the final section, so its tuple representation is (2, 4, 3).

Your code should use the variables rose1, rose2, rose3, rose4, and rose5 to output each rose, one per line. The roses should be aligned so that their right-hand sides line up and the longest rose has no spaces before its petals (the '@'). Any rose shorter than the longest rose should have an appropriate number of spaces before the '@'.

Here is starter code:

""" Rose Variables """
rose1 = (2, 4, 3)
rose2 = (5, 1, 2)
rose3 = (5, 7, 2)
rose4 = (1, 1, 10)
rose5 = (1, 1, 1)

""" Your code here """

Hints

  • Can you calculate the length of rose 1 using the data in rose1?
  • Can you put the lengths of all five roses into a list? If so, can you use list functions to find the length of the longest rose?
  • Remember that you can multiply a string by an integer to duplicate it. So "abc" * 3 is "abcabcabc".

Back to Top