Starting from:
$30

$24

Homework 6: Repeating Shapes Solution




The goal of this lab is practice testing and using all of the di
erent loops. You should work




individually on this assignment.




Getting Started



You should start by creating a folder specically for this assignment. Create a README.txt le including three things: your name, the course name, and the name of this assignment. You should also use it answer any questions that may be asked in this assignment along with including any comments that you want the grader to consider when grading your assignment. You should not include any code in your README.txt le.




Repeating Shapes



In this assignment, you are to write several functions in repeatingShapes.py that will complete a program that is capable of drawing shapes on the console. You will have already implemented some of these using while loops in previous assignments so you should be sure to use only for loops for this one.




Start by reading through the provided driver program found in repreatingShapesDriver.py .




This le contains three functions:




menu displays a menu of options to the user and reads in the user's choice form the keyboard, and ensures that the option is valid. It is used in the main function.



readInteger is used to gather di
erent integer values from the user and makes sure that the values entered by the user are all positive integers. It is used in the main function.



Finally, the main function is where the program begins by displaying the menu, and uses the option chosen by the user to required information from the user before calling a function in the shapes module. You will implement these functions.



Your submission will be evaluated against the original driver program so you should not change any of the function parameters.

Checkerboard



Design an algorithm that will draw a checkerboard. For example a checkerboard with a block size of 5, a width of 8, and a height of 7 should be:




*****
*****
*****


*****


*****
*****
*****


*****


*****
*****
*****


*****


*****
*****
*****


*****


*****
*****
*****


*****


*****


*****
*****
*****


*****


*****
*****
*****


*****


*****
*****
*****


*****


*****
*****
*****


*****


*****
*****
*****


*****
*****
*****


*****


*****
*****
*****


*****


*****
*****
*****


*****


*****
*****
*****


*****


*****
*****
*****


*****


*****


*****
*****
*****


*****


*****
*****
*****


*****


*****
*****
*****


*****


*****
*****
*****


*****


*****
*****
*****


*****
*****
*****


*****


*****
*****
*****


*****


*****
*****
*****


*****


*****
*****
*****


*****


*****
*****
*****


*****


*****


*****
*****
*****


*****


*****
*****
*****


*****


*****
*****
*****


*****


*****
*****
*****


*****


*****
*****
*****


*****
*****
*****


*****


*****
*****
*****


*****


*****
*****
*****


*****


*****
*****
*****


*****


*****
*****
*****


*****


CS 5001 S19
Homework 06 { Page 3
4 Box Grid


Design an algorithm that will draw a
x grid of boxes. For example a box grid with a block size



of 5, a grid width of 6, and a grid height of 3 should be:




Enter block size: 5




Enter grid width: 6




Enter grid height: 3




*************************************




*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*



*************************************




*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*



*************************************




*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*



*************************************

Triangle Pattern



Design an algorithm that will draw a grid of triangles. For example a triangle pattern with a size of 5, a width of 9, and a height of 4 should be:




*
*
*
*
*
*
*
*
*
**
**
**
**
**
**
**
**
**
***
***
***
***
***
***
***
***
***
****
****
****
****
****
****
****
****
****



***** ***** ***** ***** ***** ***** ***** ***** *****




*
*
*
*
*
*
*
*
*
**
**
**
**
**
**
**
**
**
***
***
***
***
***
***
***
***
***
****
****
****
****
****
****
****
****
****



***** ***** ***** ***** ***** ***** ***** ***** *****




*
*
*
*
*
*
*
*
*
**
**
**
**
**
**
**
**
**
***
***
***
***
***
***
***
***
***
****
****
****
****
****
****
****
****
****



***** ***** ***** ***** ***** ***** ***** ***** *****




*
*
*
*
*
*
*
*
*
**
**
**
**
**
**
**
**
**
***
***
***
***
***
***
***
***
***
****
****
****
****
****
****
****
****
****



***** ***** ***** ***** ***** ***** ***** ***** *****

Diamond Pattern



Design an algorithm that will draw a grid of diamonds. Just like the diamonds in the last homework assignment, diamond patterns can only have an odd size. For example a triangle pattern with a size of 5, a width of 8, and a height of 4 should be:




* * * * * * * *




*** *** *** *** *** *** *** ***




***** ***** ***** ***** ***** ***** ***** *****




***
***
***
***
***
***
***
***
*
*
*
*
*
*
*
*
***
***
***
***
***
***
***
***



***** ***** ***** ***** ***** ***** ***** *****




***
***
***
***
***
***
***
***
*
*
*
*
*
*
*
*
***
***
***
***
***
***
***
***



***** ***** ***** ***** ***** ***** ***** *****




***
***
***
***
***
***
***
***
*
*
*
*
*
*
*
*
***
***
***
***
***
***
***
***



***** ***** ***** ***** ***** ***** ***** *****




*** *** *** *** *** *** *** ***




* * * * * * * *










Submit Files to Bottlenose



Before submitting, be sure that you have added a comment at the top of your source les that includes your name and the current date. Then create an archive of the folder that you created for this assignment containing all of the les that you have created and upload this archive to Bottlenose for grading. When you upload, be sure to check whether there are any auto-graders that evaluated your code and x any issues pointed out by the auto-graders. After submitting your assignment, complete the Homework 6 Review.

More products