Requirements: Write a program to input students ' homework
1. View students ' homework
2. Input student's Operation situation
3, can allow the input 3 times, need to be empty situation
Students={' Zhang Meng Meng ', ' Chen Millet ', ' Xu Go ', ' Li not yet ', ' ran XI '} hw_dict = {' Zhang Meng Meng ': {' 2018.3.22 ': ' Not paid ', ' 2018.3.2 3 ': ' have been handed '}, ' ran XI ': {' 2018.3.22 ': ' Not paid ', ' 2018.3.23 ': ' Handed '},} for I in range (5
): Choice=input (' 1. Input student homework \n2. Check Student Jobs (enter number 1 or 2): ' "If choice== ' 1 ': name=input (' Student Name: '). Strip () Date=input (' Date: '). Strip () Hw_stu=input (' Job: '). Strip () If name in students: #判断学生信息: Whether in the student list stud
Ents if name in Hw_dict.keys (): #如果该学生在hw_dict中有记录 hw_dict[name][date]=hw_stu else: #如果该学生在hw_dict中没有记录 hw_dict.setdefault (Name,{date:hw_stu}) for K, v. in Hw_dict[n Ame].items (): #打印录入操作后该学生的作业信息 print (k, v) Break Else:print (' No in list For this student information, please add the student information first. ' Elif choice== ' 2 ': Show_name=input (' Enter the name of the student you want to query: '). Strip () If show_name in students: #判断学生信息: Yes No on student List Students if show_name in Hw_dict.keys (): #如果该学生在hw_dict中有记录 to I,j in Hw_dict[show_name].
Items (): #输出该学生的作业信息 print (I,J) break else: #如果该学生在hw_dict中没有记录
Print (' No information about the student in the job information! ') Else:print (' list does not have this student information, please add student information first. ' Else:print (' can only enter the number 1 or 2 ') else:print (' The input number is too many, no more operation. ')