1 min read
ASCII, abbreviated from American Standard Code for Information Interchange, is a character encoding standard for electronic communication. ASCII codes represent text in computers, telecommunications equipment, and other devices.
1] Create a Python Program to get the ASCII value of a given character.
The ord()
function in Python accepts a string of length 1 as an argument and returns the Unicode code point representation of the passed argument, and for the first 128 Unicode code point values are the same as ASCII.
print(ord('a'), ord('b'), ord('c'))
97 98 99
2] Create a Python Program to get the ASCII value of a user-provided character.
character = input("Enter the character")
print("The ASCII code for {} is {}".format(character, ord(character)))
Enter the character a
The ASCII code for a is 97
1] Create a Python Program to get the character from the given ASCII value.
The chr()
function in Python accepts a Unicode code point as an argument and returns the character pointing to that.
print(chr(97),chr(98))
a b
2] Create a Python Program to get the character from the user-provided ASCII value in runtime.
ascii_code = int(input("Enter The ASCII code"))
print("The character is {}".format(chr(ascii_code)))
Enter The ASCII code 97
The character is a
PROGRAMS
Latest from djangocentral
2 min read
2 min read