Advertisement
mennakhaled6

Untitled

Jul 8th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.20 KB | None | 0 0
  1.                 if(elective_human):
  2.                     elective_human = list(set(elective_human) - set(all_courses_tillnow))
  3.                     num_to_select = 1  # set the number to select here.
  4.                     list_of_random_items_human = random.sample(elective_human, num_to_select)                    
  5.                     CurrentSemester.extend(list_of_random_items_human)
  6.                                    
  7.                 length = 0
  8.                 elective_pre = []
  9.                 tempElect = []
  10.                 temptempElect = []
  11.                 while(length < 2 and elective_course):
  12.                     elective_course = list(set(elective_course) - set(all_courses_tillnow)- set(tempElect))
  13.                     num_to_select = 2 - length  # set the number to select here.
  14.                     list_of_random_items_human = random.sample(elective_course, num_to_select)                    
  15.                     elective_pre.extend(list(list_of_random_items_human))
  16.  
  17.                     for row in elective_pre:
  18.                         pre = set(Prerequisite_Course.loc[Prerequisite_Course['Course'] == row]['Prerequisite'])
  19.                         condition = all(x in all_courses_tillnow for x in pre)
  20.                         if not pre:
  21.                             temptempElect.append(row)
  22.                         elif(condition):
  23.                             temptempElect.append(row)
  24.                         elif(not condition):
  25.                             pre =list(pre - set(all_courses_tillnow))
  26.                             temptempElect.extend(pre)
  27.                            
  28.                     temptempElect = (list(set(temptempElect)))
  29.                     for (j,row) in enumerate(temptempElect):
  30.                         if temptempElect[j] not in elective_course:
  31.                             temptempElect.remove(temptempElect[j])
  32.                            
  33.                     tempElect.extend(temptempElect)  
  34.                     length=len(tempElect)
  35.                     elective_pre = []
  36.                     temptempElect = []
  37.  
  38.                 elective_course = list(set(elective_course) - set(all_courses_tillnow)- set(tempElect))
  39.                 CurrentSemester.extend(tempElect)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement