Python student achievement Management System concise version

  • 2020-06-23 01:03:32
  • OfStack

Speaking of student achievement management system, from college 1C language curriculum design, to college 2 C++ curriculum design is this problem, recently learning raspberry pie, it seems that raspberry pie often used Python programming, so learned 1 wave Python, read 1 point of basic grammar to write something to practice.

Development environment: Ubuntu+Python2.7

The code is as follows:


#coding=utf-8 
 
# Save student information  
studentList=[] 
 
def addInfo(name,addr): 
 tempInfo={} 
 tempInfo['name']=name 
 tempInfo['addr']=addr 
 studentList.append(tempInfo) 
 print(studentList) 
 
def delInfo(number): 
 if number<len(studentList) and number>=0 : 
 del studentList[number] 
 
 else: 
 print(" You entered the wrong number :") 
 
def changeInfon(modifNum,name,addr): 
 if modifNum<len(studentList) and modifNum>=0 : 
 tempInfo={} 
 tempInfo['name']=name 
 tempInfo['addr']=addr 
 studentList[modifNum]=tempInfo 
 
 else: 
 print(" You entered the wrong number :") 
 
def findInfo(findName): 
 i=0 
 for info in studentList: 
 if findName ==info['name']: 
 print(" The information you are looking for is %i %s %s"%(i,info['name'],info['addr'])) 
 
 
while True: 
 print("-"*30) 
 print(" Please enter your options ") 
 print("1. Add student information ") 
 print("2. Delete student information ") 
 print("3. Modify student information ") 
 print("4. Query student information ") 
 print("-"*30) 
 
 
# Wait for user input options  
 choose=int(raw_input(" Please enter your options :")) 
 
 
 if 1==choose: 
 name=raw_input(" Please enter the student's name :") 
 addr=raw_input(" Please enter the student's native place :") 
 addInfo(name,addr) 
 
 elif 2==choose: 
 if 0==len(studentList): 
 print(" The current system does not have any student information ") 
 continue 
 i=0 
 for info in studentList: 
 print("%i %s %s"%(i,info['name'],info['addr'])) 
 i+=1 
 number=int(raw_input(" Please enter the serial number to delete :")) 
 delInfo(number) 
 print(" The deleted information is: %s"%studentList) 
 
 elif 3==choose: 
 i=0 
 for info in studentList: 
 print("%i %s %s"%(i,info['name'],info['addr'])) 
 i+=1 
 modifNum=int(raw_input(" Please enter the serial number you want to modify :")) 
 name=raw_input(" Please enter the student's name :") 
 addr=raw_input(" Please enter the student's native place :") 
 
 changeInfon(modifNum,name,addr) 
 print(" The modified information is as follows: %s"%studentList[modifNum]) 
 
 elif 4==choose: 
 findName=raw_input(" Please enter the name of the student you are looking for :") 
 findInfo(findName) 
 
 else : 
 print(" You have typed it incorrectly , Please re-enter ") 
 continue 

For more information, please pay attention to the topic management System Development.


Related articles: