Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python programming! Question 4 Employ structured programming principles to develop a program that uses a list, attendanceList to track the attendees for an event, and

Python programming!

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Question 4 Employ structured programming principles to develop a program that uses a list, attendanceList to track the attendees for an event, and the groups (either 1, 2 or 3) assigned to them. An example content of attendanceList is shown here: [['Eileen', 1], ['Darrel', 2], ['Cynthia', 3], ['Betty', 1], ['Alice', 2]] Notice that the attendee's name and group are recorded as a list in attendanceList, e.g., ['Eileen', 1]. The example content of attendanceList can be read as Eileen is in group 1, Darrel is in group 2, Cynthia is in group 3, Betty is in group 1, and Alice is in group 2. The application provides this menu to users: Menu 1. Register Attendee 2. Locate Attendee Group 3. Display List by Group 0. Exit (a) Write a function registerAttendee() for Option 1 with attendanceList as argument. The function prompts for the attendee's name and group. If the group is not 1, 2 or 3, it displays an error message Invalid group. The function repeats prompting until a valid group is entered. The function then constructs a list with the name and group, adds it to attendanceList, and displays a message Successful attendance registration. (7 marks) (b) Write a function locateAttendeeGroup() for Option 2 with attendanceList as argument. The function prompts for an attendee's name. The function finds the name in attendanceList, and displays the attendee's name and group assigned. You may assume that names in attendancelist are unique. If the name is not in attendanceList, the function displays an error message Not in attendance list. (6 marks) (c) Write a function displayListByGroup() for Option 3 with attendanceList as argument. The function prints out the attendee sorted by group and name. An example if shown here: Betty Group: 1 Eileen Group: 1 Alice Group: 2 Darrel Group: 2 Cynthia Group: 3 (6 marks) (d) Write the application that repeatedly presents the menu and performs the requested operations until option 0 is chosen. Initialise attendanceList as an empty list. (6 marks) An example run is shown here, with user input underlined: Menu 1. Add Attendee 2. Locate Attendee Group 3. Display List by Group 2. Exit Enter choice: 1 Enter attendee name: Eileen Enter assigned table number (1, 2, 3): 5 Invalid group Enter assigned table number (1, 2, 3): 1 Successful attendee registration Menu 1. Add Attendee 2. Locate Attendee Group 3. Display List by Group e. Exit Enter choice: 1 Enter attendee name: Darrel Enter assigned table number (1, 2, 3): 2 Successful attendee registration Menu 1. Add Attendee 2. Locate Attendee Group 3. Display List by Group e. Exit Enter choice: 2 Enter attendee name: John Not in attendance list Menu 1. Add Attendee 2. Locate Attendee Group 3. Display List by Group @. Exit Enter choice: 2 Enter attendee name: Darrel Darrel is in group 2 Menu 1. Add Attendee 2. Locate Attendee Group 3. Display List by Group 2. Exit Enter choice: 1 Enter attendee name: Alice Enter assigned table number (1, 2, 3): 2 Successful attendee registration Menu 1. Add Attendee 2. Locate Attendee Group 3. Display List by Group @. Exit Enter choice: 3 Eileen Group: 1 Alice Group: 2 Darrel Group: 2 Menu 1. Add Attendee 2. Locate Attendee Group 3. Display List by Group 3. Exit Enter choice: 8 Invalid option Menu 1. Add Attendee 2. Locate Attendee Group 3. Display List by Group 2. Exit Enter choice: @ Application ends

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_2

Step: 3

blur-text-image_3

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

Database Fundamentals Study Guide

Authors: Dr. Sergio Pisano

1st Edition

B09K1WW84J, 979-8985115307

More Books

Students also viewed these Databases questions

Question

Find each definite integral. [(3x + 5) dx

Answered: 1 week ago