+1 vote
in Python by
Print the following pattern:

A

B C

D E F

G H I J

K L M N O

P Q R S T U

1 Answer

0 votes
by

Below is the program to draw the function pattern

def  pattern_6(num): 

    # initializing value equivalent to 'A' in ASCII  

    # ASCII value 

    number = 65

 

    # outer loop always handles the number of rows 

    for i in range(0, num):

        # inner loop to handle number of columns 

        # values changing acc. to outer loop 

        for j in range(0, i+1):

            # explicit conversion of int to char

# returns character equivalent to ASCII. 

            char = chr(number) 

          

            # printing char value  

            print(char, end=" ") 

            # printing the next character by incrementing 

            number = number +1    

        # ending line after each row 

        print("\r") 

num = int(input("enter the number of rows in the pattern: "))

pattern_6(num)

Related questions

+1 vote
asked Feb 15, 2021 in Python by SakshiSharma
0 votes
asked Jan 18, 2021 in Python by SakshiSharma
...