0% found this document useful (0 votes)
163 views13 pages

Aditya Kumar - Student Grading System

The document describes a student grading system project created by Aditya Kumar for a computer science class, which involves connecting a Python script to a MySQL database to perform operations like inserting, updating, deleting, and searching student records as well as calculating grades based on marks in various subjects. The code allows the user to choose different operations to manage student data in the database and print query results.

Uploaded by

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

Aditya Kumar - Student Grading System

The document describes a student grading system project created by Aditya Kumar for a computer science class, which involves connecting a Python script to a MySQL database to perform operations like inserting, updating, deleting, and searching student records as well as calculating grades based on marks in various subjects. The code allows the user to choose different operations to manage student data in the database and print query results.

Uploaded by

Vaibhav Pareta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

COMPUTER SCIENC PROJECT

STUDENT GRADING SYSTEM

Aditya Kumar
12 – F
Roll no: 3

TOPIC: Python Connectivity with MySQL


CERTIFICATE
This is to certify that the project titled
Student Grading System is prepared under
by guidance and supervision by Aditya
Kumar of class 12 – F in Computer Science
for the academic session 2020-2021

Submitted to Ms. Pallavi Sharma


Signature: __________
ACKNOWLEDGEMENT
I would like to express my special thanks of gratitude to my
computer science teacher “Ms. Pallavi Sharma” for her able
guidance and support in completing my project.

Then I would like to thank my parents and friends who have


helped me with their valuable suggestions and their guidance
has been helpful in various phases of the completion of the
project.
CODE:
import mysql.connector as database

connection=database.connect(host="localhost", user='root',
passwd='1234', database='test')
cursor=connection.cursor()

def update_record():
roll=input("Which student's details do you want to
update?\nRoll No: ")
choice=int(input("[UPDATING DETAILS]\n\n1. Roll No\n2.
Name\n3. Class\nEnter Choice : "))
print()
if choice==1:
new_roll=int(input("Enter the new roll no: "))
update=f"update students set RollNo={new_roll} where
RollNo={roll}"
cursor.execute(update)

cursor.execute("select * from students")


for i in cursor:
print(i)
elif choice == 2:
new_name=input("Enter the new name: ")
update=f'update students set Name="{new_name}"
where RollNo={roll}'

cursor.execute(update)

cursor.execute("select * from students")


for i in cursor:
print(i)

elif choice==3:
new_class=int(input("Enter the new class: "))
update=f"update students set Class={new_class} where
RollNo={roll}"
cursor.execute(update)

cursor.execute("select * from students")


for i in cursor:
print(i)
print()

def insert_record():
roll = int(input("Enter Roll No : "))
name = input("Enter Name : ")
class_int = int(input("Enter Class : "))
insert=f'insert into students
values({roll},"{name}",{class_int},"-","")'
print(insert)

cursor.execute(insert)
cursor.execute(f'select * from students where Name =
"{name}"')
print()
for i in cursor:
print(i);
print()

def delete_record():
roll=int(input("[DELETING]\n\nWhich entry would you like
to delete?\n Roll No: "))
delete=f"delete from students where RollNo={roll}"
cursor.execute(delete)
cursor.execute("select * from students");
print()
for i in cursor:
print(i)
print()

def grade():

roll = int(input("Roll No. of student : "))


mathsMarks = int(input("Maths Marks (out of 100) : "))
physicsMarks = int(input("Physics Marks (out of 100) : "))
chemMarks = int(input("Chemistry Marks (out of 100) : "))
compMarks = int(input("CS Marks (out of 100) : "))
englishMarks = int(input("English Marks (out of 100) : "))

totalMarks =
mathsMarks+physicsMarks+chemMarks+compMarks+english
Marks
percent = round((totalMarks/500)*100,2)

if percent >= 95:


grade = "A+"
elif percent >= 85 and percent < 95:
grade = "A"
elif percent >= 75 and percent < 85:
grade = "B"
elif percent >= 55 and percent < 75:
grade = "C"
elif percent >= 35 and percent < 55:
grade = "D"
else:
grade = "F"

percentStr = str(percent)+" %"

update=f"update students set percentage='{percentStr}'


where RollNo={roll}"
cursor.execute(update)
update2 = f"update students set grade='{grade}' where
RollNo={roll}"
cursor.execute(update)
print(f"\nPercentage : {percentStr} with a grade of
{grade}")
print(f'\nUpdated record for student with roll no {roll}\n')
# MAIN
while True:
choice = int(input("\nWhat operation would you like to
perform?\n1. Insert a new record\n2. Delete a record\n3.
Update a record\n4. Search for record\n5. Display ALL\n6.
Grading\n7. Exit program\nEnter Choice --->"))
print("")
if choice==1:
insert_record()
elif choice==2:
delete_record()
elif choice==3:
update_record()

elif choice == 4:

d=int(input("Enter roll no:"))


s =f'select * from students where RollNo = {d}'
cursor.execute(s)
print()
for i in cursor:
print(i)
print()
elif choice == 5:

cursor.execute("select * from students order by RollNo


asc")
print()
for i in cursor:
print(i)
print()
elif choice == 6:

grade()

elif choice == 7:

print("\nExiting the program...")


exit()

connection.commit()
OUTPUT:

You might also like