Westonci.ca makes finding answers easy, with a community of experts ready to provide you with the information you seek. Connect with a community of professionals ready to help you find accurate solutions to your questions quickly and efficiently. Discover in-depth answers to your questions from a wide network of professionals on our user-friendly Q&A platform.
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
Visit us again for up-to-date and reliable answers. We're always ready to assist you with your informational needs. We hope this was helpful. Please come back whenever you need more information or answers to your queries. We're here to help at Westonci.ca. Keep visiting for the best answers to your questions.