Algorithm


1. Start

2. Prompt the user to enter a character and store it in a variable, let's call it 'ch'.

3. Use the ord() function to convert the character 'ch' to its ASCII value.
   - ASCII_value = ord(ch)

4. Display the ASCII value.
   - Print("The ASCII value of", ch, "is", ASCII_value)

5. End

Code Examples

#1 Code Example- Finding the ASCII value of a character

Code - Python Programming


# Get the character from the user
char = input("Enter a single character: ")

# Check if the user entered a single character
if len(char) == 1:
    ascii_value = ord(char)
    print(f"The ASCII value of the character '{char}' is: {ascii_value}")
else:
    print("Please enter a single character.")
Copy The Code & Try With Live Editor

Output

x
+
cmd
The ASCII value of the character 'A' is: 65
Advertisements

Demonstration


Python Programing Example to Find ASCII Value of Character-DevsEnv