Print ASCII Value of a character in python

In this article, we will learn to find an ASCII value of a character using a python program.

ASCII stands for American Standard Code for Information Interchange and is a character encoding standard for electronic communication. ASCII codes represent text in computers.

So, to find an ASCII value in python, we use the ord() function. ord() function returns the ASCII value of a given character.



Explanation




Program

1
2
3
4
5
6
7
8
# print ascii value in python
# first we will take input from the user 
character = str(input("Enter character: "))

# now we use ord() function to find the ascii value
print("ASCII value of a given character",character,"is",ord(character))

# print ascii value in python - docodehere.com

Output

Enter character: A
ASCII value of a given character A is 65

Enter character: a
ASCII value of a given character a is 97
Next Post Previous Post
No Comment
Add Comment
comment url