Hi Guys, welcome to my blog in this article you will learn about how to Write A Python Program To Display The ASCII Code Of (A-Z) And (A-Z) Characters
Title :
Write A Python Program To Display The ASCII Code Of (a-z) And (A-Z) Characters
Description :
Hi guys, in this article you will learn a python program to print ASCII Value of English alphabets a-z and A-Z.
You need to be aware of the ord() function in Python that takes an argument as a keyboard character and gives us the ASCII value of the argument.
We will be using this ord() function to convert the English alphabets to ASCII values.
Import the ASCII lowercase and uppercase from the string module and then use the far look to iterate all the characters present in the string and convert into ASCII value and print it.
from string import ascii_lowercase, ascii_uppercase
print("ASCII Value of a-z is ...")
for letter in ascii_lowercase:
print(f"{letter} : {ord(letter)}")
Similarly use another follow to iterate the ASCII uppercase characters and using the ord() function print the respective ASCII value
print("
ASCII Value of A-Z is ...")
for letter in ascii_uppercase:
print(f"{letter} : {ord(letter)}")
Complete Python Code :
from string import ascii_lowercase, ascii_uppercase
print("ASCII Value of a-z is ...")
for letter in ascii_lowercase:
print(f"{letter} : {ord(letter)}")
print("
ASCII Value of A-Z is ...")
for letter in ascii_uppercase:
print(f"{letter} : {ord(letter)}")
Output :
ASCII Value of a-z is ...
a : 97
b : 98
c : 99
d : 100
e : 101
f : 102
g : 103
h : 104
i : 105
j : 106
k : 107
l : 108
m : 109
n : 110
o : 111
p : 112
q : 113
r : 114
s : 115
t : 116
u : 117
v : 118
w : 119
x : 120
y : 121
z : 122
ASCII Value of A-Z is ...
A : 65
B : 66
C : 67
D : 68
E : 69
F : 70
G : 71
H : 72
I : 73
J : 74
K : 75
L : 76
M : 77
N : 78
O : 79
P : 80
Q : 81
R : 82
S : 83
T : 84
U : 85
V : 86
W : 87
X : 88
Y : 89
Z : 90
Output :
ASCII Value as printed above.
Conclusion :
The above Python program uses the ASCII lowercase and uppercase string from the string module
It uses the parallel to eat red all the letters stored in ASCII love workers and uppercase stream and use as the ord() function to print the ASCII value
Comment it down below if you have any suggestions to improve the above Python program
0 Comments