Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.'

image text in transcribedPlease 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

How has the FASB used note disclosure as a tool of compromise?

Answered: 1 week ago

Question

8. Describe how cultural spaces are formed.

Answered: 1 week ago