Python_ Input Inquiry Student Homework __python

Source: Internet
Author: User
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. ')

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.