|
Small Python Programs For Beginners |
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):
for j in range(i, 64, -1):
print(chr(j), end="")
print()
alphabet(6)
The output of the code is:
A
BA
CBA
DCBA
EDCBA
FEDCBA
GFEDCBA
Comments
Post a Comment