Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. Setup your Python file lab3-2.py with an appropriate comments header. 2. Organize lab3-3.py using comments for each block of planned code. 3. Complete
1. Setup your Python file lab3-2.py with an appropriate comments header. 2. Organize lab3-3.py using comments for each block of planned code. 3. Complete the readIt () function. 4. Complete the makeSeq () function. 5. Complete the lookup () function. 6. Complete the myMenu () function. 7. Complete the main () function. 8. Submit your completed lab3-3.py Python program to BrightSpace. Before you begin, download the data files posted on BrightSpace for this assignment. Problem Description: Stiles Publishing prints custom Computer Science textbooks for Big Ten universities. They store their textbook and course data in a text file which includes six fields: 1) SemesterID, 2) CourselD, 3) TextbookID, 4) Programming Language, 4) Enrollment and the 5) Course Instructor. An example of this data can be found in Table 1. The file provided (classBooks.txt) includes data from 75 courses with associated text books published for the summer 2017 (SU2017) through spring 2018 (SP2018) semesters. Note: The data in classBooks.txt has a fixed-width format, meaning each field starts at the same position on each line. SU2017 CS336 Q5504 Java FA2017 CS230 A6107 Python FA2017 CS338 23939 Python SU2018 CS221 P7956 Visual Basic FA2018 CS230 A6107 Python SU2018 CS173 K7877 SP2018 CS190 R5803 MATLAB 118 A Chaturvedi 107 V Raskin 181 Y Charlie 166 C Nita-Rotaru 134 D Ebert 70 S Kais 224 B Benes Table 1: Example course textbook and enrollment data in a fixed-width format You have been assigned to develop an application to access this data for Stiles Publishing. Your assignment is to write a Python program file named exam3f.py including five (5) functions: readIt (): makeSeq (): lookup (): myMenu(): main (): Reads the data from the file and returns a List of values in a specific format Processes the data and creates a Dictionary summarizing each instructor's number of courses per semester. Searches the Dictionary for the courses for a given instructor Creates a Graphics window as an interface to allow the user to display an instructor's number of courses per semester and their total. Brings it all together into a single, functional program These functions work together to create a single graphical interface allowing Stiles Publishing to review summary information about their courses, textbooks and enrollment data. Detailed specifications for each function can be found in the instructions on the following pages. Part 1: Setup Your lab3-3.py Python File In the Python IDLE editor, open a new program window. At the top of the file, create an appropriate program header including the program name, your name and a short description of the program. Part 2: Organize lab3-3.py using comments There are several parts to this lab including writing multiple functions. Even within these functions, you might be able to divide the task into further smaller subtasks. We leave it to your discretion to identify these subtasks as they are necessary. Below your program header, enter additional comments in your Python program identifying each part, function and subtask. Make sure to leave blank spaces between each comment section. In your finished program, there will be comments before any lines of code to make them easier to understand. Part 3: Complete the readIt() function Write a function named readIt () that accepts one (1) argument, a String which represents a data file name, (examples of the data file are shown on in the Problem Description on page 2). The readIt () function completes the following tasks: Read the contents of the filename given in the argument into a List storing each line as a String Modify the List by splitting each element into a sub-List containing five Strings and an Integer original String element " SU2017 CS336 Q5504 Java 118 A Chaturvedi" sub-List with 5 Strings and 1 Integer ["SU2017", "CS336", "Q5504", "Java", 118, "A Chaturvedi"] Strings Return the finished List Integer Part 4: Complete the makeSeq() function Write a function named makeSeq () that accepts one (1) argument, a List and completes the following tasks: Create a Dictionary using the instructor names from the List as keys Calculate the total number of courses for each instructor for each semesterID. The Dictionary values associated with each instructor key will be a List with five (5) Integer entries representing that instructor's total number of courses per semester in the following order: SU2017, FA2017, SP2018, SU2018 and FA2018 { "D Ebert": [0,2,0,3,1], "A Chaturvedi": [2,1,2,4,1] } Note: There are 13 instructors- this is just a sample of the actual Dictionary values Return the completed Dictionary Part 5: Complete the lookup () function Write a function named lookup () that accepts two (2) arguments, (a Dictionary and a String), and completes the following tasks: If the String is not a key in the Dictionary, the lookup () function should return False Using the String as the Dictionary key, retrieve the corresponding value. This will be a List containing five (5) Integers Create a new List containing each of the five (5) Integers as well as their numeric sum. The lookup () function should return the new List. NOTE: The returned List will have six (6) values. Example: If a Dictionary is named myDict and has the key "A Chaturvedi" with the following value: >>> myDict ["A Chaturvedi"] [2, 1, 2, 4, 1] Calling the lookup () function, providing the Dictionary name and valid key would provide the result: >>> lookup (myDict, "A Chaturvedi") [2, 1, 2, 4, 1, 10] Where 10 is the numeric sum of the original five Integer values. Calling the lookup () function, providing the Dictionary name and misspelling the key: >>> lookup (myDict, "A Chatrvdi") False Part 6: Complete the myMenu() function Write a function named myMenu () that accepts one (1) argument, (a Dictionary), and completes the following tasks: If a mouse click is detected in the green LOOKUP control the String in the Instructor Name: Entry box is retrieved and passed along with the Dictionary to the lookup () function. Creates a 300 x 400 Graphic window that matches the example in Figure 1 including an Entry box object labeled Instructor Name: and two Rectangles with the labeled LOOKUP and QUIT. The LOOKUP Rectangle should have a green fill color and the QUIT should be red. Create the Rectangles and Text labels shown for each semester and total as shown in Figure 1. The entries in the List returned by the lookup () function are used to populate the enrollment Text boxes for SU2017, FA2017, SP2018, SU2018, FA2018 and Total. If the lookup () function returns a value of False, assume an invalid name was entered in the Instructor Name: Entry box. Set the enrollment Text entries for SU2017, FA2017, SP2018, SU2018, FA2018 and Total to "" empty Strings If a click is detected in the red QUIT control, the Graphic window is closed and the program ends. Stiles Publishing Course Enrollment Summary Instructor Name: LOOKUP SU2017 FA2017 SP2018 SU2018 FA2018 TOTAL Part 7: The main () function: Write a function named main() that completes the following tasks: Figure 1: Graphic window created by myMenu() function QUIT Calls the readIt () function to read the file and store the data in a List Calls the makeSeq () function to create the Dictionary Calls the myMenu () function to present the user with the Graphical menu
Step by Step Solution
★★★★★
3.42 Rating (161 Votes )
There are 3 Steps involved in it
Step: 1
Answer Here is the completed lab33py Python program with the requested functions lab33py Author Question AI This program allows Stiles Publishing to a...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started