4. Design an n-out-of-m code that could represent the letters A-Z plus a space c
ID: 3734808 • Letter: 4
Question
4. Design an n-out-of-m code that could represent the letters A-Z plus a space character and the usual punctuation symbols (. ,;:? !). 5. Design an n-out-of-m code that could code nearly the entire 128-character ASCII set. What advantage(s) would this code have over the usual 7-bit binary code? What makes your code better than other possible n-out-of-m codes? 6. Explain why a three-out-of-five code is essentially the same as a two- out-of-five code. In general, why is an n-out-of-m code equivalent to ar (m- n)-out-of-m code?Explanation / Answer
def main():
string = ' !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'
char_count = 0
white_space_count = 0
ascii_count = 0
non_ascii_count = 0
non_ascii_chars = []
text = input('Enter a text to analyze: ')
for ch in text:
char_count += 1
if ch.isspace():
white_space_count += 1
if ch in string:
ascii_count += 1
else:
non_ascii_chars.append(ch)
non_ascii_count += 1
print()
print('Total number of characters: ' + str(char_count))
print('Total number of white spaces: ' + str(white_space_count))
print('Total number of ASCII characters: ' + str(ascii_count))
print('Total number of non-ASCII characters: ' + str(non_ascii_count))
print('The non-ASCII letters were: ', end='')
for i, ch in enumerate(non_ascii_chars):
print(ch, end='')
if i != len(non_ascii_chars) - 1:
print(", ", end='')
print()
if __name__ == '__main__':
main()
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.