Python program to print A to Z alphabets
We can generate a sequence of characters between A to Z using range() function and for loop.
range() function will start from 65 (ASCII of A) and will stop at 90 (ASCII of Z). chr() function will help us in printing ASCII character of a given integer number.
Python program to print A to Z alphabets.
for i in range(65, 91):
print(chr(i), end=' ')
Output of Program
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Python program to print Z to A alphabets.
for i in range(90,64,-1):
print(chr(i), end=' ')
Output of Program
Z Y X W V U T S R Q P O N M L K J I H G F E D C B A
No comments:
Post a Comment