Quiz 4 | CMSC 105 Elementary Programming - Fall 2024

Quiz 4

Points Possible: 100

Date: Thursday, December 5th

Background

This quiz is based on the topics covered in weeks 11 through 14. There are 2 programming problems. You are allowed to use the Thonny IDE. Please see the grading rubric for each programming problem. Scratch paper and a simple calculator are allowed. You may also use the guides provided on the course web page: https://cmsc105-f24.github.io/guides

Submission

Program 1 (50 points)

You are tasked with creating a simple Python program to process a log file. The log file, named server_logs.txt, contains information about server requests in the following format:

server_logs.txt

2024-11-21 10:15:30 INFO User123 accessed /home
2024-11-21 10:20:45 ERROR User456 failed to access /dashboard
2024-11-21 10:25:50 WARNING User789 exceeded rate limit
2024-11-21 10:30:15 INFO User123 logged out

Each line contains a timestamp, a log level (INFO, ERROR, WARNING), a user identifier (e.g., User123), and a message.

The server_logs.txt file can be downloaded using this link: server_logs.txt

Remember to save the file in the same folder as your program.

Write a program to:

If the file server_logs.txt contains the sample data above, your program should print the output to the screen:

sample output:

Total lines: 4
INFO: 2
ERROR: 1
WARNING: 1
The error logs have been saved to error_logs.txt.

The contents of error_logs.txt should be:

error_logs.txt

2024-11-21 10:20:45 ERROR User456 failed to access /dashboard

Problem 2 (50 points)

Create a Course class and contains the following private data fields: netid, admission_date, major_field_study, course_name, score, and the following methods:


Draw the UML diagram for the Course class.


Write test code that prompts the instructor to enter the netid, admission_date, major_field_study, course_name and score. Initiate an object of Course class, print the details and also print the final grade.


Sample run:

Enter student's netid: dbalash
Enter student's admission_date: 07-28-2023
Enter student's major: Computer Science
Enter student's course name: Algorithms
Enter student's score: 94


Student Details:

netid: dbalash
Admission Data: 07-28-2023
Major Field of Study: Computer Science
Course Name: Algorithms
Score: 94

Final Grade: A