0% found this document useful (0 votes)
9 views

Ex38ec_Problem Statement

Uploaded by

Mahmoud
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Ex38ec_Problem Statement

Uploaded by

Mahmoud
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Exercise 38 - Extra Credit

PROBLEM STATEMENT

This problem builds on top of Exercise 38, in which you were asked to
write code to draw an hourglass. Note that there are different ways to
think about the figure (see below), and they are all legal.

3 parts 2 parts 2 parts


XXXXXXX XXXXXXX XXXXXXX
XXXXX TOP XXXXX TOP XXXXX TOP
XXX XXX XXX
X MIDDLE X X
XXX XXX XXX
XXXXX BOTTOM XXXXX BOTTOM XXXXX BOTTOM
XXXXXXX XXXXXXX XXXXXXX

There also different ways of writing the code, all of which are acceptable
for this task:
(1)Using nested for loops
(2)Using a for loop and string multiplication
(3)Using only string multiplication

So, taking as your starting point the work you did for Exercise 38, enhance
your program in the following ways:

A. Let the user choose between drawing the picture (figure) of an


hourglass (as above) or a butterfly (see Figure A below).
B. Let the user specify if they want a frame around the picture (see
Figure B). Of course, the user can choose the character to use to
draw the frame and to draw the figure and they can be different. In
Figure B, both the frame and the whitespace have thickness = 1 all
around the picture.
C. Let the user specify the width of the frame and the width of the
whitespace between the frame and the picture (see Figure C). Both
the width of the frame and the width of the whitespace should be
kept constant around the picture, but they can be different from
each other. In Figure C, the frame has thickness = 3 and the
whitespace has thickness = 2.
+++++++++++++ +++++++++++++++++++
+ + +++++++++++++++++++
* * + ||||||||| + +++++++++++++++++++
** ** + ||||||| + +++ +++
*** *** + ||||| + +++ +++
**** **** + ||| + +++ * * +++
********* + | + +++ ** ** +++
**** **** + ||| + +++ *** *** +++
*** *** + ||||| + +++ **** **** +++
** ** + ||||||| + +++ ********* +++
* * + ||||||||| + +++ **** **** +++
+ + +++ *** *** +++
+++++++++++++ +++ ** ** +++
+++ * * +++
+++ +++
+++ +++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++

Figure A Figure B Figure C


WHAT TO SUBMIT

A single Python program that can draw an hourglass or a butterfly picture,


with or without a frame, with different drawing characters for the picture
and the frame, and different sizes for the frame and the whitespace
between the frame and the picture.

GRADING

The grading will be out of 1 (1% of your course grade) and will take into
consideration all of the program evaluation criteria:

1. Effectiveness (0.4 pts): The algorithm gets the job done correctly.
2. User interaction (0.2 pts): The user is treated well.
a. Clarity: They are given information about what they are
expected to enter and provided output in a nice to read and
clear fashion.
b. Politeness: They are greeted appropriately on entry and exit.
3. Elegance (0.3 pts): This is a matter of design, under which I
included readability and modifiability. Make sure you use
whitespace and comments appropriately and breakdown your
program into appropriate functions.
4. Efficiency (0.1 pts): The algorithm gets the job done correctly and
using a minimum of resources. Here just avoid repeated
computations.

You might also like