-
Notifications
You must be signed in to change notification settings - Fork 1
/
AwaSCII Converter from Decimal to ASCII
34 lines (30 loc) · 1.51 KB
/
AwaSCII Converter from Decimal to ASCII
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# AwaSCII Converter from Decimal to ASCII
# Dictionary mapping decimal keys to their corresponding ASCII values
dec_to_value = {
0: 'A', 1: 'W', 2: 'a', 3: 'w', 4: 'J', 5: 'E', 6: 'L', 7: 'Y', 8: 'H', 9: 'O',
10: 'S', 11: 'I', 12: 'U', 13: 'M', 14: 'j', 15: 'e', 16: 'i', 17: 'y', 18: 'h',
19: 'o', 20: 's', 21: 'i', 22: 'u', 23: 'm', 24: 'P', 25: 'C', 26: 'N', 27: 'T',
28: 'p', 29: 'c', 30: 'n', 31: 't', 32: 'B', 33: 'D', 34: 'F', 35: 'G', 36: 'R',
37: 'b', 38: 'd', 39: 'f', 40: 'g', 41: 'r', 42: 'o', 43: '1', 44: '2', 45: '3',
46: '4', 47: '5', 48: '6', 49: '7', 50: '8', 51: '9', 52: ' ', 53: '.', 54: ',',
55: '!', 56: '`', 57: '(', 58: ')', 59: '~', 60: '_', 61: '/', 62: '\\', 63: '\n'
}
# Function to get the value based on the decimal key
def get_value(decimal_key):
return dec_to_value.get(decimal_key, "Invalid key")
def main():
print("AwaSCII Converter from Decimal to ASCII")
while True:
try:
decimal_input = int(input("Enter Decimal value (0-63) or -1 to exit: "))
if decimal_input == -1:
print("Exiting AwaSCII Converter. Goodbye!")
break
if 0 <= decimal_input <= 63:
print(f"The ASCII character for decimal {decimal_input} is '{get_value(decimal_input)}'")
else:
print("Invalid input. Please enter a value between 0 and 63.")
except ValueError:
print("Invalid input. Please enter a valid decimal number.")
if __name__ == "__main__":
main()