Wtite a Python script to print a range of alphabetic characters ‘a’ to ‘z’ using the custom range() function. You will need to use the ASCII character value and then convert the ASCII value to a alphabetic letter using a chr() function.
Expected Output (submit code and output): Generate the characters from a to z, inclusive.
The program is written python 3 .
using the for loop to print the ascii value of the characters. range() is used. It includes first number and excludes the second parameter. As we know in ASCII a-z is defined in 97-122. But we used 97-123 because 123 is excluded in range function.
And to print the number as character , used chr() function to represent it in alphabet or can say symbol as assigned to it in ascii format.
Here is the code
CODE:
#for loop to traverse through the ascii numbers of the
alphabets
for i in range(97,123):
#it converts the number to the character and print it
print(chr(i), end=', ')
OUTPUT:
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,
Get Answers For Free
Most questions answered within 1 hours.