Pattern
**
****
******
********
**********
Input:
Get The Number of Rows as the input and store it in n variable
Processing:
i = 1
while i <=n
print ** i times in a line
i += 1
Output:
Display The pattern according to the input of n
Algorithm:
Step1. Get the number of rows from the user and store it in n variable.
Step2. initialize i as 1
Step3. Repeat until i less than or equal to n
Step3.1 Print ** i times
Step3.2 increment the value of i by one
Step 4. End
Program:
n = eval(input())
for i in range(1,n+1):
print('**'*i,end='\n')
Flowchart:
- Given ‘n’, the number of rows, design an algorithm and write a Python code to draw a pattern. If n is ‘5’, the pattern looks as shown below:
**
****
******
********
**********
Input:
Get The Number of Rows as the input and store it in n variable
Processing:
i = 1
while i <=n
print ** i times in a line
i += 1
Output:
Display The pattern according to the input of n
Algorithm:
Step1. Get the number of rows from the user and store it in n variable.
Step2. initialize i as 1
Step3. Repeat until i less than or equal to n
Step3.1 Print ** i times
Step3.2 increment the value of i by one
Step 4. End
Program:
n = eval(input())
for i in range(1,n+1):
print('**'*i,end='\n')
Flowchart:
Why do you use double ** instead of *
ReplyDeletethe question requires us print ** in the first line then **** in the next line if you use * instead of ** then you would get only * in the first line and ** in the second line
ReplyDelete