1. Not Lonely Anymore:
A second librarian, Charlie, joins you in the school library. Charlie suggests that the book list you keep can be improved to include names of the authors. You agree. The two of you start to upgrade your automation to do the following:
- Input a line which contains the book name followed by the author's name. Both are single words.
- If the book doesn't exist in your list, add it; if it does, update the author's name.
- Handle deletion by book name as it already does.
- If the input is 'search' followed by author's name, output a list of books by this author.
- At the end of the process, output the complete book list, one line per book, each containing the book name followed by the author's name.
2. Bond, James Bond:
You live a double life. During the day you are GS the lonely librarian, but when you are off and nobody sees you, you are James Bond the MI6 secret agent, the King's spy, with a license to kill.
You can't let others know the content of your communication with M, the head of MI6. You have a secret code book jamesbondscodebooktopsecretcantletanybodyseebecauseitsnotencrypted.txt. The book contains many lines, each containing the plain text word followed by its code word. Example:
hungry *&%#
bored 78534
irritated buzzinga!
So that a message like 'I am always hungry or bored or irritated' will be translated to 'poop am always *&%# or 78534 or buzzinga!'
Input a line of message you need to send to M. Use the code book to translate it word by word to the secret form and output the translated line. Repeat this process until a blank line is input.
3. Real Legend:
The Unix system (https://en.wikipedia.org/wiki/Unix) is a legend. It sets the foundation for most of the modern-day operating systems that run on billions of devices. More importantly its design philosophy of simplicity and reusability has a massive influence on generations of programmers, in simple terms, to create a program that does one thing really well, and let it work with other programs.
The Unix system has many very famous commands which are also legends. wc is one of them. See https://en.wikipedia.org/wiki/Wc_(Unix). You want to recreate the functions of wc in Python so that you can be a real legend too.
Input the name of an existing text file. Output 3 numbers, the number of lines, the number of words (delimited by spaces), and the number of characters (including spaces and newlines).
No comments:
Post a Comment