INTRODUCTION
IN THE PROJECT
The Online Exam & Result Management
System is a Python–MySQL based application
developed as a Class 12 CBSE Computer
Science project. The system automates the
process of conducting examinations, evaluating
answers, and generating results. It reduces
paperwork, saves time, and ensures accurate
and fast evaluation.
The project uses Python IDLE for programming
logic and MySQL Workbench for database
storage and management. It fully follows the
CBSE syllabus requirements for database
connectivity and menu-driven programs.
OBJECTIVES OF THE
PROJECT
•To conduct examinations in an online
mode
•To manage a centralized question bank
•To perform automatic evaluation of
answers
•To generate result, percentage, and rank
•To analyze subject-wise performance
•To demonstrate Python–MySQL
connectivity
SYSTEM REQUIREMENTS
Hardware Requirements
Computer or Laptop
Minimum 4 GB RAM
Intel core i3 or higher processor
Software Requirements
Python 3.x (IDLE)
MySQL Server
MySQL Workbench
Windows Operating System
TOOLS & TECHNOLOGIES USED
Programming Language: Python
Database: MySQL
Connector: mysql-connector-python
IDE: Python IDLE
DATABASE DESIGN
1 students table
student_id (INT, PRIMARY KEY, AUTO_INCREMENT)
name (VARCHAR(50))
class (VARCHAR(10))
2 questions table
question_id (INT, PRIMARY KEY, AUTO_INCREMENT)
subject (VARCHAR(30))
question (VARCHAR(200))
option_a (VARCHAR(100))
option_b (VARCHAR(100))
option_c (VARCHAR(100))
option_d (VARCHAR(100))
correct_option (CHAR(1))
3 answers table
answer_id (INT, PRIMARY KEY, AUTO_INCREMENT)
student_id (INT)
question_id (INT)
selected_option (CHAR(1))
4 results table
result_id (INT, PRIMARY KEY, AUTO_INCREMENT)
student_id (INT)
subject (VARCHAR(30))
score (INT)
percentage (FLOAT)
rank (INT)
SQL TABLE CREATION QUERIES
CREATE DATABASE online_exam_system;
USE online_exam_system;
CREATE TABLE students (
student_id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50),
class VARCHAR(10)
);
CREATE TABLE questions (
question_id INT AUTO_INCREMENT PRIMARY KEY,
subject VARCHAR(30),
question VARCHAR(300),
option_a VARCHAR(100),
option_b VARCHAR(100),
option_c VARCHAR(100),
option_d VARCHAR(100),
correct_option CHAR(1)
);
CREATE TABLE answers (
answer_id INT AUTO_INCREMENT PRIMARY KEY,
student_id INT,
question_id INT,
selected_option CHAR(1)
);
CREATE TABLE results (
result_id INT AUTO_INCREMENT PRIMARY KEY,
student_id INT,
subject VARCHAR(30),
total_questions INT,
correct_answers INT,
percentage FLOAT,
grade VARCHAR(5)
);
OUTPUT SCREEN OF SQL
TABLE
COMPLETE CODE (Python-IDLE)
import [Link]
import time
# ---------------- DATABASE CONNECTION ----------------
conn = [Link](
host="localhost",
user="root",
password="yourpassword",
database="online_exam_system"
)
cursor = [Link]()
# ---------------- STUDENT FUNCTIONS ----------------
def add_student():
name = input("Enter Student Name: ")
sclass = input("Enter Class: ")
[Link](
"INSERT INTO students(name, class) VALUES(%s,%s)",
(name, sclass)
)
[Link]()
print("Student Registered Successfully")
def view_students():
[Link]("SELECT * FROM students")
data = [Link]()
print("\n--- STUDENT LIST ---")
for row in data:
print(row)
# ---------------- QUESTION FUNCTIONS ----------------
def add_question():
subject = input("Enter Subject: ")
question = input("Enter Question: ")
a = input("Option A: ")
b = input("Option B: ")
c = input("Option C: ")
d = input("Option D: ")
correct = input("Correct Option (A/B/C/D): ").upper()
[Link](
"""INSERT INTO questions
(subject, question, option_a, option_b, option_c,
option_d, correct_option)
VALUES (%s,%s,%s,%s,%s,%s,%s)""",
(subject, question, a, b, c, d, correct)
)
[Link]()
print("Question Added Successfully")
def view_questions():
[Link]("SELECT question_id, subject, question
FROM questions")
data = [Link]()
print("\n--- QUESTION BANK ---")
for row in data:
print(row)
# ---------------- EXAM FUNCTION ----------------
def start_exam():
sid = int(input("Enter Student ID: "))
subject = input("Enter Subject: ")
[Link](
"SELECT * FROM questions WHERE subject=%s",
(subject,)
)
questions = [Link]()
if len(questions) == 0:
print("No questions found for this subject")
return
correct = 0
total = len(questions)
print("\nExam Started (Answer Carefully)\n")
start_time = [Link]()
for q in questions:
print("\nQ:", q[2])
print("A.", q[3])
print("B.", q[4])
print("C.", q[5])
print("D.", q[6])
ans = input("Your Answer (A/B/C/D): ").upper()
[Link](
"INSERT INTO answers(student_id, question_id,
selected_option) VALUES(%s,%s,%s)",
(sid, q[0], ans)
)
if ans == q[7]:
correct += 1
end_time = [Link]()
duration = int(end_time - start_time)
percentage = (correct / total) * 100
if percentage >= 90:
grade = "A+"
elif percentage >= 75:
grade = "A"
elif percentage >= 60:
grade = "B"
elif percentage >= 40:
grade = "C"
else:
grade = "F"
[Link](
"""INSERT INTO results
(student_id, subject, total_questions,
correct_answers, percentage, grade)
VALUES (%s,%s,%s,%s,%s,%s)""",
(sid, subject, total, correct, percentage, grade)
)
[Link]()
print("\n Exam Completed")
print("Total Questions:", total)
print("Correct Answers:", correct)
print("Percentage:", percentage)
print("Grade:", grade)
print("Time Taken:", duration, "seconds")
# ---------------- RESULT FUNCTIONS ----------------
def view_results():
[Link]("""
SELECT [Link], [Link],
[Link], [Link]
FROM students
JOIN results ON students.student_id =
results.student_id
""")
data = [Link]()
print("\n--- RESULT REPORT ---")
for row in data:
print("Name:", row[0], "| Subject:", row[1],
"| Percentage:", row[2], "| Grade:", row[3])
# ---------------- MAIN MENU ----------------
def main_menu():
while True:
print("\n========= ONLINE EXAM SYSTEM
=========")
print("1. Add Student")
print("2. View Students")
print("3. Add Question")
print("4. View Questions")
print("5. Start Exam")
print("6. View Results")
print("7. Exit")
choice = int(input("Enter Choice: "))
if choice == 1:
add_student()
elif choice == 2:
view_students()
elif choice == 3:
add_question()
elif choice == 4:
view_questions()
elif choice == 5:
start_exam()
elif choice == 6:
view_results()
elif choice == 7:
print("Thank You for Using Online Exam System")
break
else:
print("Invalid Choice")
# ---------------- PROGRAM START ----------------
main_menu()
SAMPLE OUTPUT
ADD STUDENT OUTPUT
VIEW STUDENTS OUTPUT
ADD QUESTIONS OUTPUT
VIEW QUESTIONS OUTPUT
START EXAM OUTPUT
VIEW RESULT OUTPUT
EXIT OUTPUT
ADVANTAGES
Fast and accurate evaluation
Reduces manual work
Secure database storage
Easy result generation
LIMITATIONS
Requires computer system
Basic security only
FUTURE SCOPE
Login authentication system
Online exam timer display
Result graphs and analytics
Web-based interface
CONCLUSION
The Online Exam & Result Management System
developed using Python IDLE and MySQL
Workbench successfully fulfills the objectives of
automating the examination and result management
process. The system e iciently handles student
registration, question bank management, online
examinations, automatic evaluation, and instant
result generation.
This project demonstrates the practical application
of Python programming concepts and MySQL
database connectivity. The use of structured
programming, menu-driven options, and SQL queries
ensures accuracy, reliability, and ease of data
management. Automatic calculation of percentage
and grades reduces manual e ort and eliminates
human errors.