Articles

Program to find ascii value of a character in Python

Program to find ascii value of a character in Python


In this python programming guide, we are going to:

  • write a java program to print the ascii code of a character

Program to find the ASCII value of a character in Python

The python program to find ascii value of character is as follows:

 

# Owner : TutorialsInhand Author : Devjeet Roy

number = input("Enter a number: ").strip()

ascii_val = ord(number)

print("The ASCII value is:",ascii_val)

The output of python program to find ascii value of character using function ord() is as follows:

 

PS C:\Users\DEVJEET\Desktop\tutorialsInHand> python code.py
Enter a number: E
The ASCII value is: 69

Few important points about this program

1. We ask the user to give a character as input. The strip() function removes any extra blank spaces before and after the character.

2. The ord() function gives us the ASCII value of any character.

 

Write a java program to print the ascii code of a character snapshot:

write a java program to print the ascii code of a character

 


Basic Python Programs

Would you like to see your article here on tutorialsinhand. Join Write4Us program by tutorialsinhand.com

About the Author
Devjeet Roy
Full Stack Web Developer & Data Science Enthusiast
Page Views :    Published Date : Apr 02,2021  
Please Share this page

Related Articles

Like every other website we use cookies. By using our site you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Learn more Got it!