Here we have provided a python source code that can find the ASCII value of the user entered character. ASCII Code or value: ASCII stands for A merican S tandard C ode or I nformation I nterchange, and it is used to represent 128 characters as numbers, which include special symbols too.
Prerequisite To Calculate ASCII Value in Python
- Python Input, Output
- python ord()
Steps
- Ask the user to enter a character.
- Use the ord() function to find the ASCII code of the character.
Python Program to Find ASCII Value of Character:
Python Code:
ch = input("Enter a Character: ")
if len(ch)==0:
print("The ASCII code of",ch,"is",ord(ch))
else:
print("The ASCII code of",ch,"is",ord(ch[0]))
Output 1:
Enter a Character: A
The ASCII code of A is 65
Output 2:
Enter a Character: !
The ASCII code of ! is 33
People are also reading:
- WAP to find the average of list of numbers entered by the user
- WAP to calculate the Factorial of an Integer
- Perfect Number in C
- WAP to find the largest number amongst the numbers entered by the user
- WAP to find the divisors of a positive Integer
- WAP to Display Fibonacci Series
- WAP to swap two numbers
- C++ and Python Code to Find The Sum of Elements Above and Below The Main Diagonal of a Matrix
- C Program to Extract a Portion of String
- Python Examples
Leave a Comment on this Post