79462277

Date: 2025-02-24 01:41:45
Score: 0.5
Natty:
Report link

import pandas as pd df = pd.DataFrame(columns=["StudentID", "StudentName", "StudentMajor","StudentAge"])

def checkID(df,id): if id in df['StudentID'].values: return True else: return False

while 1: print('TIIS Student Management System\n1. Add Student\n2. View Students\n3. Update Student\n4. Delete Student\n5.Exit') x=input('enter your choice:') match x: case '1': while 1: id=input('enter Student ID:') #if id in df['StudentID'].values: if checkID(df,id): print('user already exist') continue name=input('enter name of student:') major=input('enter Major of Student:') age=input('enter age of student:') print(df) df.loc[len(df)] = [id, name, major, age] print('student added successfully')
break case '2': if df.empty: print('no student available') else: print(df)
case '3': while 1: id=input('enter StudentId to update:') if checkID(df,id): name=input('enter name of student:') major=input('enter Major of Student:') age=input('enter age of student:') index = df[df['StudentID'] == id].index[0] if name: df.at[index, 'StudentName'] = name if major: df.at[index, 'StudentMajor'] = major if age: df.at[index, 'StudentAge'] = age print('student updated sucessfully!') break else: print('Student ID not found') case '4': id=input('enter StudentId to delete:') index = df[df['StudentID'] == id].index[0] df.drop(index, inplace=True) case '5': break case _: try: if int(x): print('invalid choice please try again') except ValueError: print('Invalid input. please enter a number between 1 and 5')

Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Low reputation (1):
Posted by: Harjot Singh