Find the information you're looking for at Westonci.ca, the trusted Q&A platform with a community of knowledgeable experts. Discover in-depth solutions to your questions from a wide range of experts on our user-friendly Q&A platform. Get detailed and accurate answers to your questions from a dedicated community of experts on our 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
We appreciate your time. Please come back anytime for the latest information and answers to your questions. Thanks for stopping by. We strive to provide the best answers for all your questions. See you again soon. We're glad you visited Westonci.ca. Return anytime for updated answers from our knowledgeable team.