Python student management system and python student management system

Source: Internet
Author: User

Python student management system and python student management system

It is best to write a student management system in python.

I have never learned python, so I had to start to stick to it temporarily. I went to the Internet to find out if there were any examples. below is what I wrote by referring to another blogger. There are some errors that cannot be integrated with me, I have solved the problem.

Input ("\ n \ nPress the enter key to exit. ") def functionList (): # define the function menu print (" --------- enter the serial number and select the function --------- ") print ("") print ("-" * 14 + "1. view student information "+"-"* 14) print ("-"* 42) print ("-"* 14 +" 2. add student information "+"-"* 14) print ("-"* 42) print ("-"* 14 +" 3. delete student information "+"-"* 14) print ("-"* 42) print ("-"* 14 +" 4. modify student information "+"-"* 14) print ("-"* 42) print ("-"* 14 +" 5. search System Student "+"-"* 14) print ("-"* 42) p Rint ("-" * 14 + "6. return to the upper-level "+"-"* 14) print ("-"* 42) print ("-"* 14 +" 7. exit the student system "+"-"* 14) print (" ") def functionList2 (): # define the simple edition function menu print (" --- 1: View ---- 2: add ----- 3: delete ---- 4: Modify ---- ") print (" ------- 5: Search ------- 6: Return ------ 7: Exit ------ ") def sexInputDebug (sexInput ): # Check whether the Gender input is correct if len (sexInput) = 1 and (sexInput. lower () = "m" or sexInput. lower () = "f"): return True else: return Falsedef ageInputDebug (AgeInput): # Check whether the age input is correct if len (ageInput) = 2 and ageInput. isdigit () = True: return True else: return Falsedef IDInputDebug (IDInput): # Check whether the student ID is entered correctly if len (IDInput) = 8 and IDInput. isdigit () = True: return True else: return Falsedef nameListFunction (): # display the name of a single student nameList = [] for I in range (len (studentList )): if studentList [I] ["name"] not in nameList: nameList. append (studentList [I] ["name"]) re Turn nameListdef findNameLocation (studentname): # locate the student location by name for j in range (len (studentList): if studentList [j] ["name"] = studentname: return jdef listFunction (): # define the function for displaying existing student information for I in range (len (studentList): studentInfo = studentList [I] print ("Name: % s -- Gender: % s -- Age: % s -- Student ID: % s -- Remarks: % s -- "% (studentInfo [" name "], studentInfo [" sex "], studentInfo ["age"], studentInfo ["studentID"], studentInfo ["extra"]) Print ("") def addFunction (): # defines the addition of the student function while True: numInput = input ("----- modify the existing student remarks. Enter 1 \ n ----------- to add a new student. Enter 2:") if numInput = "2": while True: nameNoExistAdd = input ("Enter the name you want to add:") nameList = nameListFunction () if nameNoExistAdd in nameList: print ("% s already exists in the student management system" % nameNoExistAdd) print ("") else: newStudent ={} newStudent ["name"] = nameNoExistAdd while True: sexInput = input ("---- enter the gender of % s -- F: man -- m: women: "% nameNoExistAdd) if sexInputDebug (sexInput) = True: newStudent [" sex "] = sexInput break else: print (" incorrect input, enter again! ") While True: ageInput = input (" ------- enter the age indicated by % s2 digit: "% nameNoExistAdd) if ageInputDebug (ageInput) = True: newStudent ["age"] = ageInput break else: print ("incorrect input. Please enter it again! ") While True: IDInput = input (" ---------- enter the 8-digit student ID of % s: "% nameNoExistAdd) if IDInputDebug (IDInput) = True: newStudent ["studentID"] = IDInput break else: print ("incorrect input. Please enter it again! ") ExtraInput = input (" ---------- enter % s remarks: "% nameNoExistAdd) newStudent [" extra "] = extraInput studentList. append (newStudent) print ("-------------- % s has been added to the student management system" % nameNoExistAdd) print ("") print ("Name: % s -- Gender: % s -- age: % s -- Student ID: % s -- Remarks: % s -- "% (newStudent [" name "], newStudent [" sex "], newStudent [" age "], newStudent ["studentID"], newStudent ["extra"]) break elif numInput = "1": while True: nameExistAdd = Input ("------ enter the name of the student whose remarks you want to modify:") nameList = nameListFunction () if nameExistAdd in nameList: extraExistAdd = input ("----------------- enter the remarks you want to add:") j = findNameLocation (nameExistAdd) studentList [j] ["extra"] = extraExistAdd print ("--------------- remarks added --------------") print ("") print ("Name: % s -- Gender: % s -- Age: % s -- Student ID: % s -- Remarks: % s -- "% (studentList [j] [" name "], studentList [j] ["sex"], studentList [j] ["age"], stud EntList [j] ["studentID"], studentList [j] ["extra"]) print ("") break else: print ("----------------- your input name does not exist ") break else: print ("---------------- the information you entered is incorrect") def delFunction (): # define the function for deleting a student while True: nameDel = input ("--------------- enter the name you want to delete:") studentNameList = nameListFunction () if nameDel in studentNameList: j = findNameLocation (nameDel) del studentList [j] print ("------------- % s has been deleted from the student management system" % n AmeDel) print ("") break else: print ("------------------ the name you want to delete does not exist! ") Def modificunction (): # define the function for modifying students while True: nameModifi = input (" ---------------- enter the name to modify: ") studentNameList = nameListFunction () if nameModifi in attributes: print ("-------------- select the content to be modified -----------") print ("-------------- 1: Change name -------------") print ("-------------- 2: change gender ---------------") print ("-------------- 3: Modify age ---------------") print ("-------------- 4: Modify student ID -----------------") print ("---- ---------- 5: Modify remarks --------------- ") while True: choiceInput = input (" Enter: ") if choiceInput =" 1 ": newNameInput = input ("---------- enter a new name:") j = findNameLocation (nameModifi) studentList [j] ["name"] = newNameInput print ("------------ name updated ----------") print ("") break elif choiceInput = "2": while True: newSexInput = input ("---- enter a new gender -- f: man -- m: women ---") if sexInputDebug (newSexInput) = True: j = FindNameLocation (nameModifi) studentList [j] ["sex"] = newSexInput print ("------------- gender updated -------------") print ("") break else: print ("--------- incorrect input, enter again! --------- ") Break elif choiceInput =" 3 ": while True: newAgeInput = input (" ---------- enter a New Age: ") if ageInputDebug (newAgeInput) = True: j = findNameLocation (nameModifi) studentList [j] ["age"] = newAgeInput print ("------------ the age has been updated ------------") print ("") break else: print ("---------- incorrect input. Please try again! ------- ") Break elif choiceInput =" 4 ": while True: newIDInput = input (" ---------- enter a new student ID: ") if IDInputDebug (newIDInput) = True: j = findNameLocation (nameModifi) studentList [j] ["studentID"] = newIDInput print ("------------ student ID updated ------------") print ("") break else: print ("---------- incorrect input. Please try again! ------- ") Break elif choiceInput =" 5 ": newExtraInput = input (" ---------- enter a new note: ") j = findNameLocation (nameModifi) studentList [j] ["extra"] = newExtraInput print ("------------ remarks updated ------------") print ("") break else: print ("--------- incorrect input. Please enter it again! ------- ") Print (" ") break else: print (" ----------------- The name you entered does not exist! ") Print (" ") def searchFunction (): # define the function nameSearch = input (" ------------- enter the name to search: ") print ("") nameList = nameListFunction () if nameSearch in nameList: print ("------------------- % s in the student management system -----------------" % nameSearch) print ("") j = findNameLocation (nameSearch) print ("Name: % s -- Gender: % s -- Age: % s -- Student ID: % s -- Remarks: % s -- "% (studentList [j] [" name "], studentList [j] [" sex "], studentList [j] [" age "], studentList [J] ["studenID"], studentList [j] ["extra"]) print ("") else: print ("---------------- % s not in the student management system ---------------" % nameSearch) print ("") # studentList = [{"name": "Frank ", "sex": "f", "age": 33, "studentID": "312312", "extra": "" },{ "name": "Jane ", "sex": "m", "age": 45, "studentID": "324235", "extra ": ""}] # function subject print ("-" * 11 + "Welcome to student management system" + "-" * 11) print ("") print ("") functionList () while True: # enter the loop. Select userInput = input ("---------------- according to the serial number. Enter the function serial number you want to select:") print ("") if userInput = "1 ": # Show existing students and return listFunction () functionList2 () continue elif userInput = "2": # Use addFunction and return addFunction () functionList2 () continue elif userInput = "3": # Use the delete function and return delFunction () functionList2 () continue elif userInput = "4": # Use the modify function and return modificunction () functionList2 () continue elif userInput = "5": # use the search function and return searchFunction () functionList2 () continue elif userInput = "6": # Return function list functionList () continue elif userInput = "7": # exit break else: print ("---------- incorrect input. Please enter it again! ----------")

The following is the result after running:

I need to study the implementation of the specific content, but this code can be run through the test, and the friends can copy it.

Problems encountered in the process:

1. raw_input: I use 3x pyCharm. The difference from 2x is that raw_input is not recognized, but input is used.

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

Related Article

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.