You are to write a program that produces a specific text figure that is supposed to look like a rocket ship.
You must name your code file rocketship.py
.
You should exactly reproduce the format of the output described in the specification below.
This includes having identical characters and spacing.
You can use the diff testing tool on the class website to check that you program is generating the correct output.
Initially, your program will read in a single input from the python shell. The prompt for the value should look like so:
Enter rocket size: X
The user of the program may enter any value for X
greater than or equal to 2.
Using this value, your program will print out a rocket with corresponding width, height, and patterns.
Below is an example of what the program will print when a size of 2
is entered:
/**\
//**\\
///**\\\
*========*
|./\../\.|
|/\/\/\/\|
|\/\/\/\/|
|.\/..\/.|
*========*
|\/\/\/\/|
|.\/..\/.|
|./\../\.|
|/\/\/\/\|
*========*
/**\
//**\\
///**\\\
When size 3 is entered instead, notice how the rocket grows:
/**\
//**\\
///**\\\
////**\\\\
/////**\\\\\
*============*
|../\..../\..|
|./\/\../\/\.|
|/\/\/\/\/\/\|
|\/\/\/\/\/\/|
|.\/\/..\/\/.|
|..\/....\/..|
*============*
|\/\/\/\/\/\/|
|.\/\/..\/\/.|
|..\/....\/..|
|../\..../\..|
|./\/\../\/\.|
|/\/\/\/\/\/\|
*============*
/**\
//**\\
///**\\\
////**\\\\
/////**\\\\\
You can see examples of sizes 2-6 on the diff-tester website. Your program should support all of these sizes.
One way to write a Python program to draw this figure would be to write a single print statement that prints each line of the figure. However, this solution would not receive full credit. A major part of this assignment is showing that you understand while loops. In lines that have repeated patterns of characters that vary in number from line to line, represent the lines and character patterns using while loops and string multiplication.
Another significant component of this assignment is the task of generalizing the program using a single value that can be changed to adjust the size of the figure.
This assignment will be graded both on “external correctness” (whether the program runs and produces exactly the expected output) and “internal correctness” (whether your source code follows the style guidelines in this document).
This program is intended to test your knowledge of loops and nested loops. You may only use python constructs introduced in class. If you are wondering wether or not you are allowed to use something, just ask!
Continue to use functions to structure your solution in such a way that the functions match the structure of the output itself. Avoid significant redundancy; use functions so that no substantial groups of identical statements appear in your code. No print statements should appear in your main function. You do not need to use functions to capture redundancy in partial lines, such as the three groups of periods in the following line:
|.../\/\....../\/\...|
No line of your code should be over 100 characters long.
Give meaningful names to functions and variables in your code.
Follow Python’s naming standards about the format of function_and_variable_names
.
Also include a comment at the start of each function, describing its behavior.
Your comments should be in your own words.
You should read in one (and only one) value to represent the size of the pieces of the figure. Your figure must be based on that exact to receive full credit.
On any given execution your program will produce just one version of the figure. However, you should refer to the value throughout your code, so that by simply changing the value, your program would produce a figure of a different size. Your program should scale correctly for any constant value of 2 or greater.
This program is best completed in stages. We strongly recommend the following development strategy:
To summarize, you do not have to worry about the variable at first, if it makes it easier to understand. Write an initial program, using loop tables or pseudocode to help you deduce the patterns in the output. After your figure looks correct at the default size, begin a second version with the variable.
It is due on Monday, 7/3/2017 at 6:00pm.
You should put all of your code in to a python file named rocketship.py
.
Submit rocketship.py
to the associated D2L dropbox.
Following these turn-in and naming instructions closely is very important, because our grading scripts will depend on some of the details.
You may lose points if these instructions are not followed precisely!
Based on an assignment by Stuart Reges, Marty Stepp, and Allison Obourn