HOW TO PRINT A PATTERN IN PYTHON?

Akshay Ak
2 min readJun 6, 2021

--

Hello amigos! we are here to see about how to print alphabets in a pattern in python.

Firstly,what is a pattern printing?

Pattern printing is nothing but printing a single or series of characters in a order with a pattern which resembles to a shape. The patterns can be star patterns, number patterns, alphabet patterns. The patterns can be of different shapes, triangle, pyramids, etc. In this blog we are going to see how to print ‘alphabets’ in a pattern in python language.

Patterns in Python can be printed using nested for loops.

The above patterns can be printed with the help of for loops with modified print statements which forms these different patterns.

The basic idea between the printing of these patterns is the same with slight differences.

We will implement the code for the alphabet pattern.

First get an integer input from the user of how much line of pattern should be printed. Then assign a variable to the value 65(since it is the ascii value for the alphabet ‘A’).Then iterate it using for loop.

‘i in range(rows)’ in this code the range function will help us to iterate until it reaches the user’s input number.

The chr() method returns a character whose unicode point is num, an integer.For example the for the code print(chr(66)) will produce the output ‘B’ since 66 is the ASCII value of ‘B’.

Then the prints the alphabet and next it adds 1 to the variable ascii and loops again and again till j is in range.

Complete Code:

For more details refer to www.guvi.com

--

--

Akshay Ak
Akshay Ak

Written by Akshay Ak

0 Followers

JUST A VERY COMMAN MAN

No responses yet