Competitive Programming In Python |
In this article, we are going to print out the Alphabet Pattern in Python.
If you are looking for a Python Tutorial Series then it's here
Before we jump into the code, let's first understand ASCII value and ASCII character
ASCII Characters ASCII Value
A-Z 65-90
a-z 97-122
0-9 48-57
Spceial Symbols 0-47, 58-64, 91-96, 123-127
The Code Part:
def alphabet(n):
asciiValue = 65
for i in range(asciiValue, asciiValue+n+1):
alpha = i
for j in range(asciiValue, i+1):
print(chr(alpha), end="")
alpha +=1
print()
alphabet(6)
The output of the code is:
A
BC
CDE
DEFG
EFGHI
FGHIJK
GHIJKLM
Comments
Post a Comment