Given the dictionary called students which maps names to lis

Given the dictionary called students which maps names to lists of courses taken: studentDict= {\'Joe\": [\'Bio\', \'Music1], \'Sally\': [\'Chem\'/Bio\'], \'Mike1: [\'Physics\'/Chem\'], A Jill\': [\'Bio\']} Create a menu that allows the user to Add a student\'s info Print Print names Delete a student\'s info Print list of classes Names of all students in a particular class Classes for particular student Checkforstudent Quit

Solution


import random

studentDict = {\"joe\":[\'Bio\',\'music\'],\"Sally\":[\'Chem\',\'Bio\'],\"Mike\":[\'Phisycs\',\'Chem\'],\"Jil\":[\'Bio\']}
def printMain():
   print \"1. Add Student\'s Info\"
   print \"2. Print\"
   print \"3. Print names\"
   print \"4. Delete student\'s info\"
   print \"5. Print list of classes\"
   print \"6. Names of all student in perticular class\"
   print \"7. Classes for perticular student\"
   print \"8. Check for student\"
   print \"9. Quit\"

def addInfo():
   name = raw_input(\"Enter Student name:\")
   classes = raw_input(\"Enter Courses took:\")
   list = classes.split(\',\')
   studentDict[name] = list
  
def Print():
   for name in studentDict:
       list = studentDict[name]
       print name +\" Courses :\"+ str(list)

def PrintNames():
   list = []
   for name in studentDict:
       list.append(name)
   list.sort();
   for name in list:
       print name

def Delete():
   PrintNames()
   name = raw_input(\"Enter Student name:\")
   yes = int(raw_input(\"Are you sure to delete (1 for yes):\"))
   if(yes == 1):
       del studentDict[name]
      
def PrintClassesList():
   classlist = []
   for name in studentDict:
       list = studentDict[name]
       for cls in list:
           classlist.append(cls)
   classlist = set(classlist)
      
   for name in classlist:
       print name
      
def StudentNameInClass():
   PrintClassesList()
   className = raw_input(\"Enter Class name:\")
   for name in studentDict:
       classlist = studentDict[name]
       for cls in classlist:
           if(cls == className):
               print name
              
def ClassesNameOfStudent():
   PrintNames()
   name = raw_input(\"Enter Student name:\")
   classlist = studentDict[name]
   for cls in classlist:
       print cls

def CheckStudent():
   sname = raw_input(\"Enter Student name:\")
   yes = 0
   for name in studentDict:
       if(name == sname):
           yes = 1
           break
   if(yes==1):
       print sname +\" : \"+str(studentDict[sname])
   else:
       print \"The student is not in our dictionary\"
input = 1
while(input != 9):
   printMain();
   input = int(raw_input(\"Enter Your choice:\"))
   if(input==1):
       addInfo()
   elif(input==2):
       Print()
   elif(input==3):
       PrintNames()
   elif(input==4):
       Delete()
   elif(input==5):
       PrintClassesList()
   elif(input==6):
       StudentNameInClass()
   elif(input==7):
       ClassesNameOfStudent()
   elif(input==8):
       CheckStudent()
   elif(input==9):
       break
   else:
       print \"Invalid input\"
       continue
   raw_input(\"\ Prass Entre to Main Menu\")
   

 Given the dictionary called students which maps names to lists of courses taken: studentDict= {\'Joe\
 Given the dictionary called students which maps names to lists of courses taken: studentDict= {\'Joe\

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site