Python Assignment
Python Assignment
Acknowledgement
3
4
1.2 Assumption
The system assumes that all users have basic knowledge of how to operate a web-based
application.
Stored user credentials and three attempts at log in to avoid crackers.
The system shall assume, about the subjects and topics, that they will be predefined and
that users will act under these constraints.
The application is designed to run in a local environment or a secure server with access to
the file system for storing data.
The program assumes that the user will always input valid data types, such as names being
texts and contact details being numbers, among others, and follow the system prompts
correctly
2. Flowchart
Fig1:
The whole program by using flowcharts
5
The client is provided with four options as indicated in the flowchart above. Within the
diamond box is the options condition. The following true condition logic is carried out when the user's
input matches the switch condition statement. For instance, the program will open the admin window
if the user enters 1. Additionally, it will request your password and login username.
Fig2:
6
According to the admin flowchart, utilizing after admin windows first requires the admin your
login information. The task options are displayed in the windows as indicated in the switch case
following a successful login. The next task is completed once the input matching the switch case
statement is executed properly
7
Fig3:
Flowchart of Registered Lecturer
The individual must first log in with the correct login information as indicated in the lecturer
window flowchart. Task list options appear in the window following a successful login. The task can
be completed by the user as specified in the switch case. The task that follows is carried out once the
input that satisfies the condition is executed.
Fig4:
8
In the given Exam Personnel window flowchart, the user at first is required to login with correct
login information. Task list options appear in the window following a successful login. The task can
be completed by the user as specified in the switch case. The task that follows is carried out after the
input that satisfies the condition is executed.
9
3. Programming Concepts
3.1 Application of storage type (text file)
i. Text files:
The system achieves persistent storage of users, questions, and examination papers through
text files. This may be regarded as simple but effective, in that it is quite adequate for small
applications whose magnitude and data integrity are not critically dependent on some complex
database system (Fagbuyiro, 2022). In our Test Question Management System (TQMS) program, we
have implemented text files as the storage medium to store the data. Below is the example of creating
and storing the subject into the text file.
Example:
Fig 5: text file
ii. List:
Lists are a very useful variable type in Python. A list can contain a series of values. List
variables are declared by using brackets [ ] following the variable name (Fugier, 2018).
A=[] # This is a blank list variable
B = [1, 23, 45, 67] # this list creates an initial list of 4 numbers.
C = [2, 4, 'john'] # lists can contain different variable types.
10
iii. Tuple:
Purpose: One of the major use cases for tuples in Python is collections of data that need to
remain immutable. For example, predefined options: user roles or question categories.
Example: Tuples are immutable, which are used to store small amounts of data that are not
going to change, like configuration settings or item categories (Real Python, 2023).
iv. Dictionary:
Purpose: A dictionary in Python is a very helpful, inbuilt data type that stores data in the form
of key-value pairs. This is an unordered, mutable, indexed collection. All keys in a dictionary
are unique and refer to values (Tutorialspoint, n.d.).
If else statement:
The true and false parts of a given condition are executed using the if-else
statement. The if block code is executed when the condition is true, and the else
block code is carried out when the condition is false (Biswal, 2024). Below is the
figure of if else condition applied on our program:
11
Fig 6: If else
Nested if:
A nested if statement is one that is the destination of another if statement.
"Nestled if statement" describes an if statement inside another if statement. If
statements can be nested inside other if statements in Python. As a result, we can
nest if statements inside of one another (Dhanwani, 2023).
Fig 7: Nested if
12
b. Iteration:
For Loop:
An object that lets you iterate over data collections, like lists, tuples, dictionaries, and sets, is
called an iterator in Python (Ramos, Real python, 2013). The iterator design pattern, which
enables you to navigate a container and access its elements, is implemented by Python
iterators.
Fig 8: for loop
While Loop:
While a condition is True, a while loop will execute a section of code. Until the specified set of
code statements is no longer true, it will continue to execute them (Lemonaki, 2021).
Fig 9: While loop
13
We must verify that user input is valid before accepting it. This makes sure the data is what we
expected it to be. Below is the validation check of date applied on our program. It checks the input
date from the user and checks the date validity. If True then it will return the date and if fails the
validation check then it will again ask the user for correct date input.
Fig 11: Validation
14
After selecting the creating new lecturer option i.e. (case 1), the following create function gets
called.
The following create function invokes the input new user function.
15
In input_new_user function the data is collected from the user through input which gets stored
in the variable result.
16
After it, the create_user function is called in which the text file name and result is passed as
argument to it.
In the create_user function the arguments are received and the data are then written to the text
file with the name value received on the filename argument.
The above update user function accepts the arguments and writes the data into the text file.
The updated data gets reflected and written on lecturer.txt file and the updating of the lecturer
is completed.
After selection of deleting lecturer option i.e. (case 5), the following delete function gets
called.
The user is prompted to enter the username to be deleted by the following delete function. The
check_user function is then called, accepting the user's username and determining whether or not the
user is available. Additionally, the delete function—which takes two arguments, filename and
username is called if the username is available. The user with the matching username is then removed
from the lecturer.txt file by the deletes function.
19
In the above functions, filename parameter defines the text file to which the data is written.
Our Test Question Management System (TQMS) has generated several reports/data in the text file.
Some txt files generated in our program are as follows:
21
After entering choice 1 from the main panel, the admin panel will be displayed where it has 9
different choices. Create a new lecture, edit lecture details, read lecture details, view all lecture, delete
lecture, create exam personnel, delete an exam personnel, create new subject and back to new window.
After entering the data, it again goes back to admin panel and choose choice no 5 where it will delete
data of the file which we have created in lecture text file.
24
This is the input of add exam personal where the quired question of data need to enter. All this
data of personal is saved in exam personnel text.
25
Edit/Update lecturer can be seen as like how that data are being updating in the system.
To enter the lecture panel, it needs go through the main panel by entering the choice with
correct password and username.
Lecturer add the question according to it topic and subject. The question can be saved in
QnA.text file. If the subject is not according to the topic than it will show the subject not found
because of validation.
27
After entering the username and password will give choices for set A or B question can be
created in set A or set B text file.
28
4. Conclusion
The Test Questions Management System is a good illustration of many Python programming
concepts in use, including concepts on file handling, data structures, and control structures. This
project organizes such elements within a real-world application and thus shows how software can
make hard tasks easy, like test question management. The text files for storage, along with methods
that effectively process data using lists, tuples, and dictionaries, make the system functional while
being easy and simple. A little further down the road, improvements can be made like moving to
database if the system is to be deployed in bigger organizations or more advanced user management
features for making the system more robust and user-friendly.
5. References
29
Biswal, B. A. (2024, jul 10). simplelearn. Retrieved from Understanding Python If-Else Statement:
https://www.simplilearn.com/tutorials/python-tutorial/python-if-else-statement#:~:text=The
%20if%2Delse%20statement%20is,else%20block%20code%20is%20executed.
Criveti, M., & Gupta, M. (2023, December 15). Retrieved from IBM:
https://www.ibm.com/reference/python/for-loop
Fagbuyiro, D. (2022, august 26). File Handling in Python – How to Create, Read, and Write to a File.
Retrieved from freecodecamp: https://www.freecodecamp.org/news/file-handling-in-python/
Fugier, D. (2018, december 12). Python data type. Retrieved from RhinoDeveloper:
https://developer.rhino3d.com/guides/rhinopython/python-datatypes/
Lemonaki, D. (2021, august 31). freecodecamp. Retrieved from Python Do While – Loop Example:
https://www.freecodecamp.org/news/python-do-while-loop-example/#:~:text=A%20while
%20loop%20will%20always,number%20%3D%20number%20%2B%201
python. (2023, march 1). Retrieved from Python Try Except: Examples And Best Practices:
https://python.land/deep-dives/python-try-except
Python If Else Statement - Conditional Statements. (2024, June 20). Retrieved from Greeks for Greeks:
https://www.geeksforgeeks.org/python-if-else/
Ramos, L. P. (2013). Real python. Retrieved from Iterators and Iterables in Python: Run Efficient
Iterations: https://realpython.com/python-iterators-iterables/#:~:text=in%20your
%20code.-,What%20Is%20an%20Iterator%20in%20Python%3F,container%20and%20access
%20its%20elements.
30
Real Python. (2023, November 06). Python's tuple Data Type: A Deep Dive With Examples. Retrieved
from Real Python: https://realpython.com/python-tuple/
6. Appendix
7.1 Work Breakdown Table