QuestionQuestion

This assignment will demonstrate your ability to work with nested loops. Your program will print four patterns using for and while loops. First you will set a constant called MAX in your program.
That will determine the maximum number of iterations for your loops (it will be your loop control variable for all loops). For example, if MAX is set to 8, your program will print the following patterns EXACTLY as shown (note that counters go from 0 to MAX-1

Requirements
● At the top of your program set a constant called MAX. Use MAX to control your loops. This is your loop control variable.
○ When you turn in your program set MAX to 10
○ MAX will be tested with anything from 4 to 10 and must work for all those cases.
In other words, you will turn in your assignment with MAX set to 10, but it will be tested with all numbers from 4 to 10 and it must work as shown for all cases.
● Your program must output EXACTLY as shown.
● You must use nested loops for each pattern. In this case that means you will have two loops per pattern (8 total loops in your program).
○ Patterns 1 and 3 MUST use nested for loops.
○ Patterns 2 and 4 MUST use nested while loops.
● You may not use quit, return, or break anywhere in your program.
● You may use continue but the solution does not require it.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

# MAX constant
MAX = 10

# Draw Pattern 1 function
def drawPattern1():
    print("Pattern 1, using nested for loops:")
    print("----------------------------------")
    print("")
    for i in range(MAX):
       row = ""
       for j in range(MAX):
            if i == j:
                row += " "
            else:
                row += str(j)
            row += " "
       print(row)
    print("")
    print("")


# Draw Pattern 2 function
def drawPattern2():
    print("Pattern 2, using nested while loops:")
    print("----------------------------------")
    print("")
    i = 0
    while i < MAX:
       j = 0
       row = ""
       while j < MAX:...

By purchasing this solution you'll be able to access the following files:
Solution.py.

$35.00
for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Python Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats