0% found this document useful (0 votes)
23 views12 pages

Teacher and Class Management System

The document is a Python script for a Timetable Arrangement System that allows teachers to manage teacher and class details, generate timetables, and students to view their timetables. It includes functionalities for adding and deleting teachers and classes, as well as generating and viewing timetables based on user input. The script connects to a MySQL database to store and retrieve timetable data.

Uploaded by

rrmadeforcs
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views12 pages

Teacher and Class Management System

The document is a Python script for a Timetable Arrangement System that allows teachers to manage teacher and class details, generate timetables, and students to view their timetables. It includes functionalities for adding and deleting teachers and classes, as well as generating and viewing timetables based on user input. The script connects to a MySQL database to store and retrieve timetable data.

Uploaded by

rrmadeforcs
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

import random

import [Link] as msc

def Teacher():

print("----Teacher Menu----")

print("[Link] Teacher")

print("[Link] Teacher")

print("[Link] class")

print("[Link] class")

print("[Link] timetable")

print("Enter any number to go back")

print("-----------------")

try:

b = int(input("Enter what you want to do:- "))

except ValueError:

print("Enter appropriate values")

return

def AddTeacher():

try:

id = int(input("Enter teacher id:- "))

n = input("Enter teacher name:- ")

s = input("Enter subject:- ")

p = input("Enter post:- ")

sal = int(input("Enter salary:- "))

cl1 = int(input("Enter class teaching 1:- "))


cl2 = int(input("Enter class teaching 2:- "))

d = [Link](host="localhost", user="root", password="admin",


database="Time_table_arrangement")

c = [Link]()

[Link](

"insert into teacher_details values (%s, %s, %s, %s, %s, %s, %s)",

(id, n, s, p, sal, cl1, cl2)

[Link]()

print("Teacher added.")

except ValueError:

print("Enter appropriate values")

except Exception as e:

print("An unexpected error occurred:", e)

def DelTeacher():

try:

idd = int(input("Enter teacher id:- "))

d = [Link](host="localhost", user="root", password="admin",


database="Time_table_arrangement")

c = [Link]()

[Link]("delete from teacher_details where Teacher_ID = %s", (idd,))

[Link]()

print("Teacher deleted.")

except ValueError:

print("Enter appropriate values")

except Exception as e:
print("An unexpected error occurred:", e)

def AddClass():

try:

cl = int(input("Enter class:- "))

sec = input("Enter section:- ")

clt = input("Enter classtype:- ")

sub1 = input("Enter main subject 1:- ")

sub2 = input("Enter main subject 2:- ")

sub3 = input("Enter main subject 3:- ")

sub4 = input("Enter main subject 4:- ")

sub5 = input("Enter main subject 5:- ")

sub6 = input("Enter additional subject 1:- ")

sub7 = input("Enter additional subject 2:- ")

sub8 = input("Enter additional subject 3:- ")

per = int(input("Enter no. of periods:- "))

d = [Link](host="localhost", user="root", password="admin",


database="Time_table_arrangement")

c = [Link]()

[Link](

"insert into student_details values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",

(cl, sec, clt, per, sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8)

[Link]()

print("Class added.")

except ValueError:
print("Enter appropriate values")

except Exception as e:

print("An unexpected error occurred:", e)

def DelClass():

try:

cld = int(input("Enter class:- "))

secd = input("Enter section:- ")

d = [Link](host="localhost", user="root", password="admin",


database="Time_table_arrangement")

c = [Link]()

[Link]("delete from student_details where Class = %s and Section = %s", (cld, secd))

[Link]()

print("Class deleted.")

except ValueError:

print("Enter appropriate values")

except Exception as e:

print("An unexpected error occurred:", e)

def GenTT():

try:

d = [Link](host="localhost", user="root", password="admin",


database="Time_table_arrangement")

c = [Link]()

cle = int(input("Enter class:- "))

sece = input("Enter sec:- ")

# example: only handling for class 12 sections A, B, C


if cle == 12 and [Link]() == 'a':

# some example timetable update logic

print("Generating timetable for 12A ...")

# (rest of your random timetable code goes here)

# ...

print("Generated")

print("---------")

elif cle == 12 and [Link]() == 'b':

print("Generating timetable for 12B ...")

# ...

print("Generated")

print("----------")

elif cle == 12 and [Link]() == 'c':

print("Generating timetable for 12C ...")

# ...

print("Generated")

print("----------")

else:

print("Entered class doesn't exist in our database")

except ValueError:

print("Enter appropriate values")

except Exception as e:

print("An unexpected error occurred:", e)

if b == 1:

AddTeacher()
elif b == 2:

DelTeacher()

elif b == 3:

AddClass()

elif b == 4:

DelClass()

elif b == 5:

GenTT()

else:

print("Enter a valid number")

print("--------------------")

def student():

print("----Student Menu----")

print("[Link] class to view timetable")

print("[Link] subjectwise timetable")

print("[Link] practical classes")

print("[Link] theory classes")

print("Enter any number to go back")

try:

f = int(input("Enter what you want to do:- "))

except ValueError:

print("Enter appropriate values")

return
def ViewTT():

try:

ec = input("Enter your class:- ")

scv = input("Enter your section:- ")

escv = ec + scv

d3 = [Link](host="localhost", user="root", password="admin",


database="Time_table_arrangement")

c3 = [Link]()

[Link]("select * from {}".format(escv))

tt = [Link]()

print("DAY/Period","-"*5,"P1","-"*13,"P2","-"*13,"P3","-"*13,"P4","-"*13,"P5","-"*13,"P6","-"*
13,"P7","-"*13,"P8")

for i in tt:

# assuming each row has 9 columns: day + 8 periods

# adjust spacing

print(i[0], "-", i[1], "-", i[2], "-", i[3], "-", i[4], "-", i[5], "-", i[6], "-", i[7], "-", i[8])

except Exception as e:

print("Either entered class/section doesn't exist or")

print("Recheck and enter appropriate values")

print("Error:", e)

print("-----------------")

def SubTT():

try:

ecd = input("Enter your class:- ")


scd = input("Enter your section:- ")

escd = ecd + scd

print("Abbreviations used","-"*2,"Subject")

print("Phy","-"*17,"Physics")

print("Chem","-"*16,"Chemistry")

print("Math","-"*16,"Mathematics")

print("Eng","-"*17,"English")

print("Bio/CS--for 12a","-"*6,"Biology/Computer Science")

print("PHE/PAI","-"*13,"Physical Education/Painting")

print("Lib","-"*17,"Library")

print("G & C","-"*15,"Counselling and guidance")

print("Math/Hindi--for 12b,12c","-"*1,"Mathematics/Hindi")

print("Bio--for 12b","-"*9,"Biology")

print("CCA","-"*17,"Co-curricular Activities")

print("Phy/Chem PR","-"*9,"Physics/Chemistry Practical")

print("Bio/CS PR","-"*11,"Biology/Computer Science Practical")

print("Eco","-"*17,"Economics")

print("Hist","-"*16,"History")

print("Geo","-"*17,"Geography")

print("Eco PR","-"*14,"Economics Practical")

subd = input("Enter subject:- ")

d8 = [Link](host="localhost", user="root", password="admin",


database="Time_table_arrangement")

c8 = [Link]()

for period in range(1,9):

[Link](f"select day from {escd} where P{period} like '%{subd}%'")


rows = [Link]()

for row in rows:

print(f"P{period} {row[0]}")

except Exception as e:

print("Enter appropriate values")

print("Error:", e)

def PrTT():

try:

ecf = input("Enter your class- ")

scf = input("Enter your section:- ")

escf = ecf + scf

d9 = [Link](host="localhost", user="root", password="admin",


database="Time_table_arrangement")

c9 = [Link]()

for period in range(1,9):

[Link](f"select day, P{period} from {escf} where P{period} like '%PR%'")

rows = [Link]()

for row in rows:

print(f"P{period} {row[0]} {row[1]}")

except Exception as e:

print("Enter appropriate values")

print("Error:", e)

def ThTT():

try:
ece = input("Enter your class:- ")

sce = input("Enter your section:- ")

esce = ece + sce

print("Abbreviations used","-"*2,"Subject")

print("Phy","-"*17,"Physics")

print("Chem","-"*16,"Chemistry")

print("Math","-"*16,"Mathematics")

print("Eng","-"*17,"English")

print("Bio/CS--for 12a","-"*6,"Biology/Computer Science")

print("PHE/PAI","-"*13,"Physical Education/Painting")

print("Lib","-"*17,"Library")

print("G & C","-"*15,"Counselling and guidance")

print("Math/Hindi--for 12b,12c","-"*1,"Mathematics/Hindi")

print("Bio--for 12b","-"*9,"Biology")

print("CCA","-"*17,"Co-curricular Activities")

print("Phy/Chem PR","-"*9,"Physics/Chemistry Practical")

print("Bio/CS PR","-"*11,"Biology/Computer Science Practical")

print("Eco","-"*17,"Economics")

print("Hist","-"*16,"History")

print("Geo","-"*17,"Geography")

print("Eco PR","-"*14,"Economics Practical")

sre = input("Enter subject:- ")

d7 = [Link](host="localhost", user="root", password="admin",


database="Time_table_arrangement")

c7 = [Link]()

for period in range(1,9):


[Link](f"select day from {esce} where P{period} = %s", (sre,))

rows = [Link]()

for row in rows:

print(f"P{period} {row[0]}")

print("-----------------")

except Exception as e:

print("Enter appropriate values")

print("Error:", e)

if f == 1:

ViewTT()

elif f == 2:

SubTT()

elif f == 3:

PrTT()

elif f == 4:

ThTT()

else:

print("Enter a valid no.")

print("-----------------")

def main():

while True:

print("----Welcome to Timetable Arrangement System----")

print("Enter 1 for Teacher")

print("Enter 2 for Student")


print("Enter 3 to Exit")

try:

a = int(input("Enter who you are:- "))

except ValueError:

print("Enter appropriate values")

continue

if a == 1:

Teacher()

elif a == 2:

student()

elif a == 3:

print("----Thank you----")

break

else:

print("Enter appropriate number")

if __name__ == "__main__":

main()

rrmadeforcs@[Link]

pass rrmadeforcs123

You might also like