IDNLearn.com is your trusted platform for finding reliable answers. Discover in-depth and reliable answers to all your questions from our knowledgeable community members who are always ready to assist.
Sagot :
Using the knowledge in computational language in python it is possible to write a code that write the binary code
Writting the code:
#function that will convert the text to binary
def text_to_binary(text):
#variable to store the converted binary value
binary_text = ""
#iterate for each character in the text
for i in text:
#get the ASCII value of that character
ascii = ord(i)
#call the function to get the value of the
#current ascii number and append it to the
#binary_text
binary_text += decimal_to_binary(ascii)
#return the final converted binary value
return binary_text
def decimal_to_binary(decimal_value):
binary_base = 2
num_bits_desired = 8
binary_value = str(bin(decimal_value))[2:]
while len(binary_value) < num_bits_desired:
binary_value = "0" + binary_value
return binary_value
text = input("Input the string you would like to encode: ")
binary = text_to_binary(text)
print(binary)
See more about python at brainly.com/question/18502436
#SPJ1
We value your participation in this forum. Keep exploring, asking questions, and sharing your insights with the community. Together, we can find the best solutions. Your search for solutions ends here at IDNLearn.com. Thank you for visiting, and come back soon for more helpful information.