Example #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"
Example #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"
Example #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
Example #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
Example #5
0
    def new_course(courses, branches):
        c_id = raw_input("Enter Course ID: ")
        while c_id == "":
            print "Incorrect format, Course ID cannot be blank."
            c_id = raw_input("Enter Course ID: ")

        if c_id in courses:
            print "\n\nERROR! Course already registered!\n\n"
            return

        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): ")
        name = raw_input("Enter course name: ")
        while not validations.name(name):
            name = raw_input("Enter course name: ")
        cred = raw_input("Enter credits: ")
        while not validations.cred(cred):
            cred = raw_input("Enter credits: ")
        sem = raw_input("Enter sem: ")
        while not validations.sem(sem, c_type.upper()):
            sem = raw_input("Enter sem: ")
        br = raw_input("Enter branch: ")
        b_id = -1
        for key in branches:
            if branches[key]["name"] == br:
                b_id = key
                break
        if b_id == -1:
            print "\n\nERROR! No such branch exists!\n\n"
            return

        courses[c_id] = {
            "c_type": c_type.upper(),
            "name": name,
            "b_id": b_id,
            "cred": cred,
            "sem": sem
        }
        print "\nCourse " + c_id + ": " + courses[c_id][
            "name"] + " registered successfully.\n\n"
Example #6
0
    def modify_course(courses):
        c_id = raw_input("Enter course ID: ")
        if c_id not in courses:
            print "\n\nERROR! No such course exists!\n\n"
            return

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

        print "Current credits:", cou["cred"]
        cred = raw_input("Enter Credits: ")
        if cred != "":
            while not validations.cred(cred):
                cred = raw_input("Enter Credits: ")
            cou["cred"] = cred
Example #7
0
	def modify_course(courses):
		c_id = raw_input("Enter course ID: ")
		if c_id not in courses:
			print "\n\nERROR! No such course exists!\n\n"
			return

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

		print "Current credits:", cou["cred"]
		cred = raw_input("Enter Credits: ")
		if cred != "":
			while not validations.cred(cred):
				cred = raw_input("Enter Credits: ")
			cou["cred"] = cred
Example #8
0
	def new_course(courses, branches):
		c_id = raw_input("Enter Course ID: ")
		while c_id == "":
			print "Incorrect format, Course ID cannot be blank."
			c_id = raw_input("Enter Course ID: ")

		if c_id in courses:
			print "\n\nERROR! Course already registered!\n\n"
			return

		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): ")
		name = raw_input("Enter course name: ")
		while not validations.name(name):
			name = raw_input("Enter course name: ")
		cred = raw_input("Enter credits: ")
		while not validations.cred(cred):
			cred = raw_input("Enter credits: ")
		sem = raw_input("Enter sem: ")
		while not validations.sem(sem, c_type.upper()):
			sem = raw_input("Enter sem: ")
		br = raw_input("Enter branch: ")
		b_id = -1
		for key in branches:
			if branches[key]["name"] == br:
				b_id = key
				break
		if b_id == -1:
			print "\n\nERROR! No such branch exists!\n\n"
			return

		courses[c_id] = {
		"c_type": c_type.upper(),
		"name": name,
		"b_id": b_id,
		"cred": cred,
		"sem": sem
		}
		print "\nCourse " + c_id + ": " + courses[c_id]["name"] + " registered successfully.\n\n"