Question: Here was the initial task: Follow these steps: Create a new Python file in this folder called pattern.py. Write code to output the star pattern

Here was the initial task: Follow these steps: Create a new Python file in this folder called pattern.py. Write code to output the star pattern shown below, using an if-else statement in combination with a single for loop (its really easy with two, but using only one takes a little more thought!):

*

**

***

****

*****

****

***

**

*

This was my feedback: 'The task requires the use of a single for loop; however, I noticed that four were used. Here's a tip: have you considered setting the loop to iterate 9 times, then using an if statement to multiply and print out a star for each iteration as long as the current number is less than 6? You can then use an 'else' statement to print out the remaining numbers. Analyzing these numbers will give you an idea of the values you need to subtract from them to achieve the desired pattern.'

Here was the initial task: Follow these steps: Create a new PythonPlease could someone help me with the recommended modifications to my program?

File Edit Selection View Go Run Terminal Help pattern.py C. left upward triangle star pattern rows =5 for i in range(1, rows+1): \# internal loop run for i times for k in range(1, i+1): print("*", end=" ") print( ) \#left downaward triangle star pattern rows =4 for i in range(rows): \#internal loop run for n - i times (conveys reversal of direction) for j in range(rows - i): print('*', end=" ') print()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!