DAT 51 Exam 2 (10 points but you can earn up to 15 points) Instructions: There are 2 graded questions and 1 extra credit question. Save your code for each question as an executable .py file. If the...

DAT 51 Exam 2 (10 points but you can earn up to 15 points) Instructions: There are 2 graded questions and 1 extra credit question. Save your code for each question as an executable .py file. If the code does not run, it will not be given any credit. Question 1 (5 points) Download the attached file “Question1.txt.” Write a program to read in this file. Then, print only the words that are 1 or 2 letters long, with each word on a separate line. If your program runs correctly, it should produce the following output: Suppose you are writing a program for StoresRUs! Unlike other stores, StoresRUs! does not serve customers on a first-come first-serve basis. Instead, it randomly selects a customer from those waiting in line. Implement a class Line that does the following: Question 2 (5 points): a. Inherits from the built-in classlist. b. Constructor takes as input a list and initializes object to this list; otherwise, initializes object to an empty list. c. Method putInLine takes customer’s name as input and puts at end of line. d. When user enters the object name, it prints “People in line:” and the names. Sample output Question 3 (5 points) – EXTRA CREDIT Continuing from Question 2, implement a method serve in class Line that does the following: 1. Prompts user for the number of customers to serve 2. If the number entered is not a number, then raises an exception and ask user to enter a number 3. Randomly chooses customers to serve and remove from the line.
Oct 12, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here