Syntax:
ord(character);
Example:
Input:
char_var = 'A'
Function call:
ord(char_var)
Output:
65
Python code to find the ASCII value of a character
# python program to print ASCII
# value of a given character
# Assigning character to a variable
char_var = 'A'
# printing ASCII code
print("ASCII value of " + char_var + " is = ", ord(char_var))
char_var = 'x'
# printing ASCII code
print("ASCII value of " + char_var + " is = ", ord(char_var))
char_var = '9'
# printing ASCII code
print("ASCII value of " + char_var + " is = ", ord(char_var))
Output