Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

04. (Part A, 5 points) Suppose you are given a definition of an exception class, which raises an error message when an username cannot be

image text in transcribed
04. (Part A, 5 points) Suppose you are given a definition of an exception class, which raises an error message when an username cannot be found in the list of username. See the definition below: usernames ('ABC', 'DEF') #list of accepted usernames class UsernameNotFound(Exception): def-init-(self, username): #dummy initialization of username self.username username def_ str_(self ): return self.username+"not found!" Suppose user enters an invalid usernameXYZ' "XYZ' is not present in the list of accepted usernames. Define and handle the appropriate exception for this class using try-except. Your answer here: (Part B, 5 point) Suppose you are designing a FIFO (First in first out) queue for a message passing system and you need to receive(put) and deliver (get) stream of messages. Each of the message is separated with a comma() and has a timestamp with it in the format of Month- Day. Message and timestamp are separated by a # character. "Hi there#Jan-20", "Hello again#Jan-10", "See u tomorrow#Mar-29", "Got ticketesiFeb4" Write down the order the messages will be received (note the timestamp). 1. 2. 3. 4. Write down the order of the messages they will be delivered. 1. 2. 3 4

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

More Books

Students also viewed these Databases questions

Question

=+ What is the standard deviation?

Answered: 1 week ago

Question

2. How can competencies be used in employee development?

Answered: 1 week ago