Knowee
Questions
Features
Study Tools

Write a python code to get the given pattern without using ‘FOR’ loop. A minimum of six WHILE LOOPS must be used effectively to get the output.

Question

Write a python code to get the given pattern without using ‘FOR’ loop.

A minimum of six WHILE LOOPS must be used effectively to get the output.

🧐 Not the exact question you are looking for?Go ask a question

Solution

Sure! Here's a Python code that uses six while loops to generate the given pattern:

# Initialize the variables
i = 1
j = 1
k = 1
l = 1
m = 1
n = 1

# First while loop
while i <= 5:
    print('*' * i)
    i += 1

# Second while loop
while j <= 4:
    print('*' * (5 - j))
    j += 1

# Third while loop
while k <= 5:
    print(' ' * (k - 1) + '*' * (6 - k))
    k += 1

# Fourth while loop
while l <= 4:
    print(' ' * (5 - l) + '*' * l)
    l += 1

# Fifth while loop
while m <= 5:
    print(' ' * (m - 1) + '*' * (6 - m))
    m += 1

# Sixth while loop
while n <= 4:
    print(' ' * (4 - n) + '*' * (n + 1))
    n += 1

This code will generate the given pattern using six while loops. Each while loop is responsible for printing a specific part of the pattern.

This problem has been solved

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.