示例#1
0
    def new_student(students, branches):
        roll = raw_input("Enter roll no.: ")
        while roll == "":
            print "Incorrect format, Roll no. cannot be blank."
            roll = raw_input("Enter roll no.: ")

        if roll in students:
            print "\n\nERROR! Student already registered!\n\n"
            return

        name = raw_input("Enter name: ")
        while not validations.name(name):
            name = raw_input("Enter name: ")
        c_type = raw_input("Enter course type (UG/PG): ")
        while not validations.c_type(c_type.upper()):
            c_type = raw_input("Enter course type (UG/PG): ")
        sex = raw_input("Enter sex: ")
        while not validations.sex(sex.upper()):
            sex = raw_input("Enter sex: ")
        dob = raw_input("Enter dob (YYYY-MM-DD): ")
        while not validations.date(dob):
            dob = raw_input("Enter dob (YYYY-MM-DD): ")
        doa = raw_input("Enter Date of Admission (YYYY-MM-DD): ")
        while not validations.doa(doa, dob, c_type):
            doa = raw_input("Enter doa (YYYY-MM-DD): ")
        ph = raw_input("Enter phone number: ")
        while not validations.phno(ph):
            ph = raw_input("Enter phone number: ")
        addr = raw_input("Enter Address: ")
        br = raw_input("Enter branch: ")
        b_id = -1
        for key in branches:
            if branches[key]["name"] == br.upper():
                b_id = key
                break
        if b_id == -1:
            print "\n\nERROR! No such branch exists!\n\n"
            return
        students[roll] = {
            "name": name,
            "c_type": c_type,
            "dob": dob,
            "doa": doa,
            "sex": sex.upper(),
            "addr": addr,
            "ph_no": ph,
            "b_id": b_id
        }
        print "\nStudent " + roll + ": " + students[roll][
            "name"] + " registered successfully.\n\n"
示例#2
0
	def new_student(students, branches):
		roll = raw_input("Enter roll no.: ")
		while roll == "":
			print "Incorrect format, Roll no. cannot be blank."
			roll = raw_input("Enter roll no.: ")

		if roll in students:
			print "\n\nERROR! Student already registered!\n\n"
			return

		name = raw_input("Enter name: ")
		while not validations.name(name):
			name = raw_input("Enter name: ")
		c_type = raw_input("Enter course type (UG/PG): ")
		while not validations.c_type(c_type.upper()):
			c_type = raw_input("Enter course type (UG/PG): ")
		sex = raw_input("Enter sex: ")
		while not validations.sex(sex.upper()):
			sex = raw_input("Enter sex: ")
		dob = raw_input("Enter dob (YYYY-MM-DD): ")
		while not validations.date(dob):
			dob = raw_input("Enter dob (YYYY-MM-DD): ")
		doa = raw_input("Enter Date of Admission (YYYY-MM-DD): ")
		while not validations.doa(doa, dob, c_type):
			doa = raw_input("Enter doa (YYYY-MM-DD): ")
		ph = raw_input("Enter phone number: ")
		while not validations.phno(ph):
			ph = raw_input("Enter phone number: ")
		addr = raw_input("Enter Address: ")
		br = raw_input("Enter branch: ")
		b_id = -1
		for key in branches:
			if branches[key]["name"] == br.upper():
				b_id = key
				break
		if b_id == -1:
			print "\n\nERROR! No such branch exists!\n\n"
			return
		students[roll] = {
			"name": name,
			"c_type": c_type,
			"dob": dob,
			"doa": doa,
			"sex": sex.upper(),
			"addr": addr,
			"ph_no": ph,
			"b_id": b_id 
		}
		print "\nStudent " + roll + ": " + students[roll]["name"] + " registered successfully.\n\n"
示例#3
0
    def modify_student(students):
        roll = raw_input("Enter roll no. of the student: ")
        if roll not in students:
            print "\n\nERROR! Student not registered!\n\n"
            return

        stu = students[roll]
        print "Leave the fields blank to retain old values\n\n"
        print "Current name:", stu["name"]
        name = raw_input("Enter name: ")
        if name != "":
            while not validations.name(name):
                name = raw_input("Enter name: ")
            stu["name"] = name

        print "Current sex:", stu["sex"]
        sex = raw_input("Enter sex: ")
        if sex != "":
            while not validations.sex(sex.upper()):
                sex = raw_input("Enter sex: ")
            stu["sex"] = sex

        print "Current DOB:", stu["dob"]
        dob = raw_input("Enter dob (YYYY-MM-DD): ")
        if dob != "":
            while not validations.date(dob):
                dob = raw_input("Enter dob (YYYY-MM-DD): ")
            stu["dob"] = dob

        print "Current Date of Admission:", stu["dob"]
        doa = raw_input("Enter Date of Admission (YYYY-MM-DD): ")
        if doa != "":
            while not validations.doa(doa, dob, stu["c_type"]):
                doa = raw_input("Enter Date of Admission (YYYY-MM-DD): ")
            stu["doa"] = doa

        print "Current phone number:", stu["ph_no"]
        ph = raw_input("Enter phone number: ")
        if ph != "":
            while not validations.phno(ph):
                ph = raw_input("Enter phone number: ")
            stu["ph_no"] = ph

        addr = raw_input("Enter Address: ")
        if addr != "":
            students[roll]["addr"] = addr
示例#4
0
	def modify_student(students):
		roll = raw_input("Enter roll no. of the student: ")
		if roll not in students:
			print "\n\nERROR! Student not registered!\n\n"
			return

		stu = students[roll]
		print "Leave the fields blank to retain old values\n\n"
		print "Current name:", stu["name"]
		name = raw_input("Enter name: ")
		if name != "":
			while not validations.name(name):
				name = raw_input("Enter name: ")
			stu["name"] = name

		print "Current sex:", stu["sex"]
		sex = raw_input("Enter sex: ")
		if sex != "":
			while not validations.sex(sex.upper()):
				sex = raw_input("Enter sex: ")
			stu["sex"] = sex

		print "Current DOB:", stu["dob"]
		dob = raw_input("Enter dob (YYYY-MM-DD): ")
		if dob != "":
			while not validations.date(dob):
				dob = raw_input("Enter dob (YYYY-MM-DD): ")
			stu["dob"] = dob

		print "Current Date of Admission:", stu["dob"]
		doa = raw_input("Enter Date of Admission (YYYY-MM-DD): ")
		if doa != "":
			while not validations.doa(doa, dob, stu["c_type"]):
				doa = raw_input("Enter Date of Admission (YYYY-MM-DD): ")
			stu["doa"] = doa

		print "Current phone number:", stu["ph_no"]
		ph = raw_input("Enter phone number: ")
		if ph != "":
			while not validations.phno(ph):
				ph = raw_input("Enter phone number: ")
			stu["ph_no"] = ph

		addr = raw_input("Enter Address: ")
		if addr != "":
			students[roll]["addr"] = addr