AP 2324 Spring A1
AP 2324 Spring A1
Spring 2023-2024
Advanced Programming
Assignment 1
due by Sunday, April 05, 2024 - 23:59
Submission Guidelines
• Make sure your Python code compiles. Any non-compiling code will receive a very low
mark.
• Carefully read the questions and pay special attention to sentences that involve “should”,
“should not”, “do not”, and other underlined/bold font statements.
• If you use code from a resource (website, book, etc.), make sure that you reference those
resources at the top of your source code file in the form of comments. You should give
details of which part of your code is from what resource. Failing to do so may result
in a plagiarism investigation.
• Any similarity in your source codes will have serious consequences for both parties.
1
Question 1 - Graphical User Interface - Tkinter (20 Pts)
Design a tkinter GUI application for user registration. Utilize the provided screenshot of
the GUI layout as a reference to create the application (Figure1,2). Include entry widgets
for the user’s name and age, along with radio buttons for selecting the user’s gender. Add
a submit button to register the user. Upon submitting the form, display the entered user
details.
• (10 Pts) Write a Python code using Tkinter GRID layout that will produce the given
GUI (Figure 1,2) output screen with the related functionality.
• (10 Pts) Write a Python code using Tkinter PACK layout that will produce the given
GUI (Figure 1,2) output screen with the related functionality.
2
Q2: Task-based Functions (57 Pts)
In this question you are going to create a function for each of the following tasks:
• [Task-1] (5 Pts) Set up a new virtual environment named ”asgmt1” and install three
Python packages. Once the packages are installed, generate a requirements.txt.
Please upload the requirements.txt file generated, and in a separate file, provide a
list of all the commands you used.
• [Task-2] (16 Pts) Using the given “udata.json” file, implement a code for each of
the following tasks.
– [Task-2.1] List all the course codes and their corresponding course names.
– [Task-2.2] Determine the total number of credits for all courses in the Faculty
of Engineering.
• [Task-3] (16 Pts) Using the given “sdata.xlsx” file, implement a code for each of the
following tasks.
– [Task-3.4] Who is the oldest student in the dataset? What is their age?
• [Task-4] (10 Pts) Write a Python function that opens a file named ”words.txt”,
calculates the frequency of each letter in the file, and then writes these frequencies
along with the corresponding letters into a new file named ”freq words.txt” in the
format of {frequency: [letter1, letter2, ...]} pairs.
• [Task-5] (10 Pts) Write a Python program that prompts the user to enter two numbers.
Handle the case where the user enters non-numeric input gracefully, displaying an error
message. Then, perform division on the two numbers and handle the ZeroDivisionError
if the second number is zero.
3
Q3: Algorithm and Flowcharts (23 Pts)
Assume that a student inputs his/her lab marks for programming in Python class. The
marks are integers. When the student enters a negative number, it means that he/she is
done with the entering of his/her marks.
In this exercise, we want you to find the average of the marks after the instructor removes
the worst 3 lab marks. If the students enters less than 4 marks, then print the average of
these entered marks. Otherwise, remove the three worst numbers and calculate the average
of the remaining marks. For example, if a student enters
12 98 45 24 56 89 33 -1
The program should output : 72 for the average of 98 45 56 89
and for
12 98 -10
it should print 55 for the average of 12 and 98.