What's new

Help Pa help po python

Phc - Jemz

Forum Guru
Elite
The program should create a list of students with the following information:

Student ID No.:

First Name:

Last Name:

Course:

Grade:

Contact No.:

Email:

The program should have an option for encoding student details and a search option to view student records individually.
 
To make a program with the above requirements in Python, you can use dictionaries to store student details and a list to manage the students. Here is a sample solution:

Python:
students = []

def add_student():
    student = {}
    student['Student ID No.'] = input('Enter Student ID: ')
    student['First Name'] = input('Enter First Name: ')
    student['Last Name'] = input('Enter Last Name: ')
    student['Course'] = input('Enter Course: ')
    student['Grade'] = input('Enter Grade: ')
    student['Contact No.'] = input('Enter Contact No: ')
    student['Email'] = input('Enter Email: ')
    students.append(student)

def search_student():
    search_id = input('Enter Student ID to Search: ')
    for student in students:
        if student['Student ID No.'] == search_id:
            print(student)
            break
    else:
        print('No Student Found')

while True:
    print('1. Add Student')
    print('2. Search Student')
    print('3. Exit')
    choice = input('Enter Your Choice: ')
    if choice == '1':
        add_student()
    elif choice == '2':
        search_student()
    elif choice == '3':
        break
    else:
        print('Invalid Choice')

In this program, two functions are defined: add_student() for adding a new student and search_student() for searching a student by their ID. The while loop continuously asks the user for their choice until they choose to exit.

Please note that this program is a basic implementation and it doesn't have any error handling logic. In a real-world application, you'd want to validate the inputs and handle any potential errors appropriately.
 

Similar threads

Back
Top