***********************Using Python and info at end of thread*************************************Thank you :) This is t

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

***********************Using Python and info at end of thread*************************************Thank you :) This is t

Post by answerhappygod »

***********************Using Python and info at end ofthread*************************************Thank you :)
Using Python And Info At End Of Thread Thank You This Is T 1
Using Python And Info At End Of Thread Thank You This Is T 1 (155.95 KiB) Viewed 42 times
This is the info for the CSV file. I'm not sure how to attachthe actual file.
[1] Objectives: This assignment focuses on using lists to store and retrieve data. You will create a database system that manages student records such that you can search for or add student information. You will practice breaking the problem into smaller pieces (functions). I will provide you with one function dealing with file reading which we have not studied yet. [2] Description: You will build a student data management system that will be able to do the following operations: • Show all records • Get a specific student record • Add a new record to the database • Exit the database (without saving changes) A student record consists of five attributes: • Student ID: A 5-digit unique numeric (integer) code represents a student. • Student name: The first and last name of a student (string) • Major: The major's code (4-letter) of the student (string) • Entry: The semester the student entered the university, such as '20173' or '20161' (5-digit string) • GPA: The Grade Point Average of the student ranges from 0.00-4.00 (float) The five attributes stored in a list form a student record. Since we have many students, we will use a list to store all the student records (a list of lists). The list of lists is your primary data structure. The program should display a menu and repeatedly prompt the user to select which operation to perform. The user will input a numeric code corresponding to an option shown below. Welcome to the student data management system Student Record Menu System: (1) Display all records (2) Get a student record (3) Add new student record (0) Exit Enter option code:
import csv def read_file (record_file): dblist = [] with open (record_file, 'r') as stu_file: records csv. reader (stu_file) for row in records: dblist.append([int (row[0]), row [1], row [2], row[3], float (row[4]]]) return dblist student_db = read_file('student_records.csv') For example, the following list [28349, 'Rose Victoria', 'CHEM', '20201', 3.80] is a sample student record. A list of two student records looks like this: [[28349, 'Rose Victoria', 'CHEM', '20201¹, 3.80], [28359, 'Mary Victoria', 'cosc', '20203', 3.99]] The program will execute the requested operation and continue to prompt the user for input until the code for Exit is entered, after which the program will stop. The operations presented in the menu should have the following effects: • Show all records: go through the entire dataset list and print all the attributes of each student with a header that specifies what each column represents. Get student record: Request the user to input a student ID and search the database for that student. If found, print the student record, or if not found, print that a student with the specified ID does not exist. • Add new student record: Request the user to input a student ID for the new record and search the database for that student. If a record with the student ID already exists, inform the user that the record cannot be added and return to the menu. If the ID is available, request the user to input the student's name, major, entry semester, and GPA. Compile this input into a list and add it to the student database list. • Exit: stop the loop which causes the menu and prompt system to show up and exit the program. There is NO need to save the updated dataset. Just leave.
specified ID does not exist. • Add new student record: Request the user to input a student ID for the new record and search the database for that student. If a record with the student ID already exists, inform the user that the record cannot be added and return to the menu. If the ID is available, request the user to input the student's name, major, entry semester, and GPA. Compile this input into a list and add it to the student database list. • Exit: stop the loop which causes the menu and prompt system to show up and exit the program. There is NO need to save the updated dataset. Just leave. [3] Requirements: As mentioned previously, the dataset will be a list where each element is a list containing five elements related to student information (a list of lists). This means that for the ith student, their attributes will be: student_db[0]: student ID (integer) student_db[1]: student name (string) student_db[2]: major (string) student_db[3]: entry semester (string) student_db[4]: GPA (float) In addition, you should implement one function for each of the operations: display one record, display all records (which you can call the first one to help), search for a record, adding a record into the database.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply