25 lines
621 B
Python
Executable File
25 lines
621 B
Python
Executable File
def text_to_ascii(text):
|
|
# Convert text to ASCII values
|
|
ascii_values = [ord(char) for char in text]
|
|
return ascii_values
|
|
|
|
def text_to_binary(text):
|
|
# Convert text to binary values
|
|
binary_values = ['{0:08b}'.format(ord(char)) for char in text]
|
|
return binary_values
|
|
|
|
def main():
|
|
user_input = input("Bitte geben Sie einen Text ein: ")
|
|
|
|
ascii_output = text_to_ascii(user_input)
|
|
binary_output = text_to_binary(user_input)
|
|
|
|
print("\nASCII Werte:")
|
|
print(ascii_output)
|
|
|
|
print("\nBinär Werte:")
|
|
print(' '.join(binary_output))
|
|
|
|
if __name__ == "__main__":
|
|
main()
|