Program to print ASCII value of the given character in Python

by | Jan 17, 2021 | Python Programs

Home » Python » Python Programs » Program to print ASCII value of the given character in Python

Introduction

ASCII stands for American Standard Code for Information Interchange. It is a standard which allocate numbers, alphabets and special characters in 8-bit code.  In python we have pre-defined function ord() which directly converts the input to its ASCII value.

Program to print ASCII value of the given character

Program

value = input("Enter the character: ")
output = ord(value)
print("The ASCII value of {0} is {1}".format(value, output))

 

Output:

Program to print ASCII value of the given character Output

Explanation

In the above python code, we have created a variable value to store the user input. The ord() function is pre-defined python function which converts the strings to its ASCII value. The ASCII value is stored in variable output and is displayed using print() function.

Author

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Author