Problem solving in Python Problem 1: This newly opened school in your neighborhood is interested in getting an automated
Posted: Tue May 24, 2022 8:10 am
Problem solving in Python
Problem 1:
This newly opened school in your neighborhood is interested in
getting an
automated tool to manage their students’ details in bulk. The
person in charge at
the school want the following operations to be implemented in the
tool:
1. Have the possibility to input the number of students he wants to
register.
2. Provide the following student’s details: Last name, first name,
level of
education and age.
3. Have the possibility to choose the operation to perform on
students’ details:
a. Search for a specific student by their last name
b. Add students’ details to a text file
c. Retrieve data from the text file.
The program shall therefore include the following functions:
• Function menu()
o This function shall display the menu as follows:
Menu:
1) Search for a student
2) Add students' details to the file
3) Retrieve students' details
4) Exit
o If the user type number 1: the function searchStudent() shall
be
invoked.
o Il the user type number 2: the function addtoFile() shall be
invoked.
o If the user type number 3: the function getData() shall be
invoked.
o If the user type number 4: the function exit() shall be
invoked.
o After the call of each of these functions, the user should have
to
choose to perform another operation.
• Function searchStudent()
o This function prompts the user for the last name of the students
and
returns their corresponding details (first name, level of education
and
age)
• Function addtoFile()
o This function creates a text file and store all the data input
(students’
details) in it.
o Once done, it shall display on the screen the following
message:
“Students’ details have been successfully saved!”
• Function getData()
o This function read all the content from the text file.
• Function exit()
o This function displays the following message: “Goodbye!” and
exits
the program.
Hint: The student’s details should be stored in a dictionary as
follow:
Key: last name
Value: (first name, level of education, age)
Problem 1:
This newly opened school in your neighborhood is interested in
getting an
automated tool to manage their students’ details in bulk. The
person in charge at
the school want the following operations to be implemented in the
tool:
1. Have the possibility to input the number of students he wants to
register.
2. Provide the following student’s details: Last name, first name,
level of
education and age.
3. Have the possibility to choose the operation to perform on
students’ details:
a. Search for a specific student by their last name
b. Add students’ details to a text file
c. Retrieve data from the text file.
The program shall therefore include the following functions:
• Function menu()
o This function shall display the menu as follows:
Menu:
1) Search for a student
2) Add students' details to the file
3) Retrieve students' details
4) Exit
o If the user type number 1: the function searchStudent() shall
be
invoked.
o Il the user type number 2: the function addtoFile() shall be
invoked.
o If the user type number 3: the function getData() shall be
invoked.
o If the user type number 4: the function exit() shall be
invoked.
o After the call of each of these functions, the user should have
to
choose to perform another operation.
• Function searchStudent()
o This function prompts the user for the last name of the students
and
returns their corresponding details (first name, level of education
and
age)
• Function addtoFile()
o This function creates a text file and store all the data input
(students’
details) in it.
o Once done, it shall display on the screen the following
message:
“Students’ details have been successfully saved!”
• Function getData()
o This function read all the content from the text file.
• Function exit()
o This function displays the following message: “Goodbye!” and
exits
the program.
Hint: The student’s details should be stored in a dictionary as
follow:
Key: last name
Value: (first name, level of education, age)