Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

From time to time Yetis who live high up in the Himalayan mountain ranges come down from the mountains to deliver a profound message, in

image text in transcribed

From time to time Yetis who live high up in the Himalayan mountain ranges come down from the mountains to deliver a profound message, in their own language, to the folks in the plains. The folks in the plains look forward to listening to these profound messages. The Yetis' language is called Yetian where the characters, as we know, are represented by 3 digits which cannot be understood by the folks in the plains. Hence, Yetis' come with a translator so that everyone listening to the message can understand it. This time around, Yowie the Yeti came down to deliver the message, but forgot to bring the translator. Mr. Coder in the plains has asked you to help code a translator based on the following rules that he gathered from his previous experiences with the Yetis. - Yeti messages always contain three digits for each character, unless a mistake has been made. Hence, the length of a valid Yeti message is always a multiple of three. - Each set of three digits translates directly to an English character using the ch r (] function which translates a decimal number to it's ASCII character equivalent (see the partial ASCII code table below for some codes and their characters). - Yeti messages transform to all lowercase English alphabet characters, except for where Yetis intend to have a space between words. A space is represented using the decimal ASCII character code for "Y", i.e., 089, rather than the normal code 032. Hence, all Yeti 3-digit characters fall in the range 097 to 122 , or 089 as a space. Write a Python program, in a file called yetian_decoder.py, which asks for a string of digits (the Yetis" message) and converts the message into English by building the message, one character at a time, using the following functions: - function isValidYeti that, given the message as a string, returns True if the number of digits in the message is a multiple of three, otherwise it returns False - function de codeDigits that, given a 3-character code string, returns the decoded string as the equivalent ASCII character; note that if the character ends up being an uppercase " Y ", a space should be returned instead - function decodeMsg which, given the complete string of digits, uses repetition to extract three digits at a time, calls the function decodeDigits and, character by character, builds and eventually returns the decoded message - function main that allows the user to enter any message as a string of digits and, using the functions mentioned above, checks to see if it is a valid string and, if so, decodes the message and prints the original encoded message, along with the decoded message; if the message is not a valid Yeti string then a message is printed indicating this fact

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M. Ricardo, Susan D. Urban, Karen C. Davis

4th Edition

1284231585, 978-1284231588

More Books

Students also viewed these Databases questions

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago