In Python, you can get the ASCII value of a character using the ord() function. This function takes a single character (a string of length 1) as an argument and returns its corresponding ASCII value. Here’s an example:
char = ‘A’
ascii_value = ord(char)
print(f”The ASCII value of ‘{char}’ is {ascii_value}”)
In this case, the output will be 65, which is the ASCII value for the character ‘A’. Similarly, you can use ord() with any character to retrieve its respective ASCII code, helping with encoding and other character-based operations.