fork download
  1. def get_student_courses(self, student_id: int) -> list:
  2. l4 = [] # List to store course codes for the student
  3. l5 = [] # List to store course names
  4. r7 = pd.read_csv('enroll.csv') # Read the enroll CSV
  5. r8 = pd.read_csv('courses.csv') # Read the courses CSV
  6.  
  7. # Loop through enrolled courses to find courses for the student
  8. for i, j in zip(r7['student_id'].values, r7['course_code'].values):
  9. if i == student_id:
  10. l4.append(j) # Append the course code
  11.  
  12. # Loop through course codes to find corresponding course names
  13. for x in l4:
  14. if x in r8['code'].values:
  15. y = r8[r8['code'] == x] # Filter courses for the current code
  16. l5.append(y['name'].values) # Extend name list with the found names
  17.  
  18. return l5 # Return list of course namesget_most_popular_course()
Success #stdin #stdout 0.04s 9772KB
stdin
Standard input is empty
stdout
Standard output is empty