Write a program that prints the following patterns separately, one below the other each pattern separated from the next by one blank line. Use for loops to generate the patterns. All aster- isks (*) should be printed by a single statement of the form print '*', (which causes the asterisks to print side by side separated by a space). (Hint: The last two pat- terns require that each line begin
with an appropriate number of blanks.) Extra credit: Combine your code from the four separate problems into a single program that prints all four patterns side by side by making clever use of nested for loops. For all parts of this program—minimize the numbers of asterisks and spaces and the number of statements that print these characters.
![15009|489x135](upload://iNnub69JKG6J5ZiX4fe1GtdHjvJ.png)
```
# Prints patterns of asterisks.
for counter in range( 1, 12 ):
# prints counter asterisks on each line
for x in range( 1, counter ):
print "*",
print # prints a new line
print # print a blank line
for counter in range( 1, 12 ):
# prints 11 - counter asterisks on each line
for x in range ( 11, counter, -1 ):
print "*",
print # new line
for counter in range ( 1, 11 ):
# prints counter - 1 spaces on each line
for x in range ( 1, counter ):
print " ",
# prints 11 - counter asterisks on each line
for x in range ( 11, counter, -1 ):
print "*",
print
for counter in range ( 1, 12 ):
# prints 11 - counter spaces on each line
for x in range ( 11, counter, -1 ):
print " ",
# prints counter asterisks on each line
for x in range ( 1, counter ):
print "*",
print
```
![15011|494x572](upload://c9R1o65fdAvseebPD2yxTeYlUiU.png)
You might also like to view...
The primary mouse button is typically the button on the left
Indicate whether the statement is true or false
Based on the assumption that the earth was round, Columbus’s goal was to find a shorter way to India by going west instead of east. He encountered America instead of India. Discuss the discovery of America by Columbus using the terminology and issues introduced in this chapter.
What will be an ideal response?