ASCII value ranges from 0 to 127 so you have to print all the characters that are represented by these values.
ASCII notation is used for exchanging the information between two computers so this is the standard followed. let's write a Python program to print all the ASCII characters
In Python this is only two line code.
Write a Python Program to Print All ASCII Character With Their Values
Take a for loop and iterate from the 0 to 128, we are considering 128 because we also need the 127 value. using the for loop, iterate and get the index. within the index print the ASCII value and character by using chr() function call.
chr() function call is used to convert an ASCII value into a character. And using the print statement we are printing the ASCII character from 0 to 127. As shown below two lines of code.
for index in range(128):
print(f"ASCII Value is : {index} ASCII Character is : {chr(index)}")
Python complete working code to print ASCII characters
=====================================================
for index in range(128):
print(f"ASCII Value is : {index} ASCII Character is : {chr(index)}")
OUTPUT
===================
ASCII Value is : 0 ASCII Character is :
ASCII Value is : 1 ASCII Character is :
ASCII Value is : 2 ASCII Character is :
ASCII Value is : 3 ASCII Character is :
ASCII Value is : 4 ASCII Character is :
ASCII Value is : 5 ASCII Character is :
ASCII Value is : 6 ASCII Character is :
ASCII Value is : 7 ASCII Character is :
ASCII Value is : 8 ASCII Character is :
ASCII Value is : 9 ASCII Character is :
ASCII Value is : 10 ASCII Character is :
ASCII Value is : 11 ASCII Character is :
ASCII Value is : 12 ASCII Character is :
ASCII Value is : 13 ASCII Character is :
ASCII Value is : 14 ASCII Character is :
ASCII Value is : 15 ASCII Character is :
ASCII Value is : 16 ASCII Character is :
ASCII Value is : 17 ASCII Character is :
ASCII Value is : 18 ASCII Character is :
ASCII Value is : 19 ASCII Character is :
ASCII Value is : 20 ASCII Character is :
ASCII Value is : 21 ASCII Character is :
ASCII Value is : 22 ASCII Character is :
ASCII Value is : 23 ASCII Character is :
ASCII Value is : 24 ASCII Character is :
ASCII Value is : 25 ASCII Character is :
ASCII Value is : 26 ASCII Character is :
ASCII Value is : 27 ASCII Character is :
ASCII Value is : 28 ASCII Character is :
ASCII Value is : 29 ASCII Character is :
ASCII Value is : 30 ASCII Character is :
ASCII Value is : 31 ASCII Character is :
ASCII Value is : 32 ASCII Character is :
ASCII Value is : 33 ASCII Character is : !
ASCII Value is : 34 ASCII Character is : "
ASCII Value is : 35 ASCII Character is : #
ASCII Value is : 36 ASCII Character is : $
ASCII Value is : 37 ASCII Character is : %
ASCII Value is : 38 ASCII Character is : &
ASCII Value is : 39 ASCII Character is : '
ASCII Value is : 40 ASCII Character is : (
ASCII Value is : 41 ASCII Character is : )
ASCII Value is : 42 ASCII Character is : *
ASCII Value is : 43 ASCII Character is : +
ASCII Value is : 44 ASCII Character is : ,
ASCII Value is : 45 ASCII Character is : -
ASCII Value is : 46 ASCII Character is : .
ASCII Value is : 47 ASCII Character is : /
ASCII Value is : 48 ASCII Character is : 0
ASCII Value is : 49 ASCII Character is : 1
ASCII Value is : 50 ASCII Character is : 2
ASCII Value is : 51 ASCII Character is : 3
ASCII Value is : 52 ASCII Character is : 4
ASCII Value is : 53 ASCII Character is : 5
ASCII Value is : 54 ASCII Character is : 6
ASCII Value is : 55 ASCII Character is : 7
ASCII Value is : 56 ASCII Character is : 8
ASCII Value is : 57 ASCII Character is : 9
ASCII Value is : 58 ASCII Character is : :
ASCII Value is : 59 ASCII Character is : ;
ASCII Value is : 60 ASCII Character is : <
ASCII Value is : 61 ASCII Character is : =
ASCII Value is : 62 ASCII Character is : >
ASCII Value is : 63 ASCII Character is : ?
ASCII Value is : 64 ASCII Character is : @
ASCII Value is : 65 ASCII Character is : A
ASCII Value is : 66 ASCII Character is : B
ASCII Value is : 67 ASCII Character is : C
ASCII Value is : 68 ASCII Character is : D
ASCII Value is : 69 ASCII Character is : E
ASCII Value is : 70 ASCII Character is : F
ASCII Value is : 71 ASCII Character is : G
ASCII Value is : 72 ASCII Character is : H
ASCII Value is : 73 ASCII Character is : I
ASCII Value is : 74 ASCII Character is : J
ASCII Value is : 75 ASCII Character is : K
ASCII Value is : 76 ASCII Character is : L
ASCII Value is : 77 ASCII Character is : M
ASCII Value is : 78 ASCII Character is : N
ASCII Value is : 79 ASCII Character is : O
ASCII Value is : 80 ASCII Character is : P
ASCII Value is : 81 ASCII Character is : Q
ASCII Value is : 82 ASCII Character is : R
ASCII Value is : 83 ASCII Character is : S
ASCII Value is : 84 ASCII Character is : T
ASCII Value is : 85 ASCII Character is : U
ASCII Value is : 86 ASCII Character is : V
ASCII Value is : 87 ASCII Character is : W
ASCII Value is : 88 ASCII Character is : X
ASCII Value is : 89 ASCII Character is : Y
ASCII Value is : 90 ASCII Character is : Z
ASCII Value is : 91 ASCII Character is : [
ASCII Value is : 92 ASCII Character is : \
ASCII Value is : 93 ASCII Character is : ]
ASCII Value is : 94 ASCII Character is : ^
ASCII Value is : 95 ASCII Character is : _
ASCII Value is : 96 ASCII Character is : `
ASCII Value is : 97 ASCII Character is : a
ASCII Value is : 98 ASCII Character is : b
ASCII Value is : 99 ASCII Character is : c
ASCII Value is : 100 ASCII Character is : d
ASCII Value is : 101 ASCII Character is : e
ASCII Value is : 102 ASCII Character is : f
ASCII Value is : 103 ASCII Character is : g
ASCII Value is : 104 ASCII Character is : h
ASCII Value is : 105 ASCII Character is : i
ASCII Value is : 106 ASCII Character is : j
ASCII Value is : 107 ASCII Character is : k
ASCII Value is : 108 ASCII Character is : l
ASCII Value is : 109 ASCII Character is : m
ASCII Value is : 110 ASCII Character is : n
ASCII Value is : 111 ASCII Character is : o
ASCII Value is : 112 ASCII Character is : p
ASCII Value is : 113 ASCII Character is : q
ASCII Value is : 114 ASCII Character is : r
ASCII Value is : 115 ASCII Character is : s
ASCII Value is : 116 ASCII Character is : t
ASCII Value is : 117 ASCII Character is : u
ASCII Value is : 118 ASCII Character is : v
ASCII Value is : 119 ASCII Character is : w
ASCII Value is : 120 ASCII Character is : x
ASCII Value is : 121 ASCII Character is : y
ASCII Value is : 122 ASCII Character is : z
ASCII Value is : 123 ASCII Character is : {
ASCII Value is : 124 ASCII Character is : |
ASCII Value is : 125 ASCII Character is : }
ASCII Value is : 126 ASCII Character is : ~
ASCII Value is : 127 ASCII Character is :
Conclusion
====================
Execute the above program on a terminal or the command prompt and note down the results.
Comment down below if you have any suggestions to improve the above ASCII Python program
0 Comments