Get Website Learn Coding Tech Story

Python Programming Examples

#!/usr/bin/evn python

# Take character as input from the user
char = input("Enter a character: ")

# ord() function covert character to relevant ASCII value
print("The ASCII value of '" + char + "' is",ord(char))

# Take input from the user and convert into integer
asci = int(input("Enter a ASCII value (int): "))

# chr() function use to convert integer (ASCII) to relevant character
print("The ASCII value of '",asci,"' is",chr(asci))

#***** Output *****
Enter a character: b
The ASCII value of 'b' is 98
Enter a ASCII value (int): 100
The ASCII value of '100' is d

Learn more about ord() and chr()