(CODE MUST BE WRITTEN IN PYTHON) (NO 'END' PARAMETER AND NO FUNCTIONS), please read carefully This exercise asks you to draw the following target composed of concentric rectangles (view inserted image) A target is composed of n rectangles centered on the middle of the target. These rectangles are of dimensions 3x3, 7x7, 11x11 and so on. The largest rectangle is composed of characters "1", the second largest of characters "2", and so on. All other characters are spaces. The character in the center of the target is always a space, and the characters around the target are always "1". You should draw a target consisting of 3 rectangles by printing it in the console. However, it should be easy to change the number of rectangles, so that you can draw a different target. You can assume, however, that the number of rectangles requested will always be between 1 and 9 inclusive, since the rectangles must be composed of the numbers 1 to 9. The target must be drawn in a single call to print. You will need to generate the text for the target and then print it at the end of the program. To do this, you must use loops. Note that this will require you to generate text that contains line breaks to separate the rows in your design. However, there must be no line breaks at the end of the design, after the last row of the target. You may not use the multiplication operator on strings. You are also not allowed to use function definitions and must not use the end parameter. Hint: a trick to drawing this target is to use the maximum norm. The distance between two points (x1, y1) and (x2, y2) defined by the maximum norm is equal to max(abs(x1 - x2), abs(y1 - y2)). Note that a character in the drawing is a digit if and only if its distance defined by the maximum norm from the center is odd, otherwise the character is a space.
(CODE MUST BE WRITTEN IN PYTHON) (NO 'END' PARAMETER AND NO FUNCTIONS), please read carefully
This exercise asks you to draw the following target composed of concentric rectangles
(view inserted image)
A target is composed of n rectangles centered on the middle of the target. These rectangles are of dimensions 3x3, 7x7, 11x11 and so on. The largest rectangle is composed of characters "1", the second largest of characters "2", and so on. All other characters are spaces. The character in the center of the target is always a space, and the characters around the target are always "1".
You should draw a target consisting of 3 rectangles by printing it in the console. However, it should be easy to change the number of rectangles, so that you can draw a different target. You can assume, however, that the number of rectangles requested will always be between 1 and 9 inclusive, since the rectangles must be composed of the numbers 1 to 9.
The target must be drawn in a single call to print. You will need to generate the text for the target and then print it at the end of the program. To do this, you must use loops. Note that this will require you to generate text that contains line breaks to separate the rows in your design. However, there must be no line breaks at the end of the design, after the last row of the target.
You may not use the multiplication operator on strings. You are also not allowed to use function definitions and must not use the end parameter.
Hint: a trick to drawing this target is to use the maximum norm. The distance between two points (x1, y1) and (x2, y2) defined by the maximum norm is equal to max(abs(x1 - x2), abs(y1 - y2)). Note that a character in the drawing is a digit if and only if its distance defined by the maximum norm from the center is odd, otherwise the character is a space.
Step by step
Solved in 2 steps