Computer Science, asked by theintelligent99, 3 months ago

Write the function called print_pattern that takes integer number as argument and prints the following pattern if the input number is 3
in python​

Answers

Answered by TechDevaansh
1

Steps to print pattern in Python

How to print pattern in Python

Decide the number of rows and columns

There is a typical structure to print any pattern, i.e., the number of rows and columns. We need to use two loops to print any pattern, i.e., use nested loops.

The outer loop tells us the number of rows, and the inner loop tells us the column needed to print the pattern.

Accept the number of rows from a user using the input() function to decide the size of a pattern.

Iterate rows

Next, write an outer loop to Iterate the number of rows using a for loop and range() function.

Iterate columns

Next, write the inner loop or nested loop to handle the number of columns. The internal loop iteration depends on the values of the outer loop.

Print star or number

Use the print() function in each iteration of nested for loop to display the symbol or number of a pattern (like a star (asterisk *) or number).

Add new line after each iteration of outer loop

Add a new line using the print() function after each iteration of the outer loop so that the pattern display appropriately

Answered by Manav1235
3

Answer:

please make me brilliant

Explanation:

def print_pattern (x) :

for i in range (1, x + 1) :

print (i * "*")

num = int (input ("Enter the number : - "))

print_pattern (num)

Similar questions