Cs Write Up
Cs Write Up
PROJECT ON
JNVST EXAM
name : R SHANMUKHAVARDHAN
2022-2023
ACKNOWLEDGEMENT:-
Signature of Principal
Purpose :-
The purpose of JNVST EXAM is to take test in an efficient manner and
no time wasting for checking the paper. The main objective of this project is to
efficiently evaluate the candidate thoroughly through a fully automated system
that not only saves lot of time but also gives fast results. For students they give
papers according to their convenience and time and there is no need of using
extra thing like paper, pen etc.
Introduction:
This JNVSTST exam project has been written in Python Programing language.
The project file contains a python script. This is a console based system which
is very easy to understand and use. Talking about the project, it contains the
following functions:
1. home()
2. admin_login()
3. student()
4. result()
5. remove_student()
6. exam()
7. check_results()
8. add_question()
9. remove_student()
Modules used:
1. import mysql.connector as ms
2. import os
3. from clrprint import *
4. import random
5. from tabulate import tabulate
6. import time as tt
Python Source code:
Home function:
def home():
while True:
while True:
ch=input('\n1.Admin Login\n2.Student\n3. Exit')
if ch.isdigit():
break
else:
print('Enter a valid choice')
ch=int(ch)
if ch==1:
admin_login()
elif ch==2:
student()
elif ch==3:
mycursor.close()
exit()
else:
clrprint('\nEnter valid choice\n',clr='r')
Admin function:
def admin_login():
while True:
password=input('\nEnter password')
if password=='@jnv':
while True:
while True:
ch=input('\n1. ADD QUESTION\n2. REMOVE QUESTION\n3. REMOVE A
STUDENT\n4. CHECK RESULTS\n5. LOG OUT')
if ch.isdigit():
break
else:
print('enter a valid choice')
ch=int(ch)
if ch==2:
remove_question()
elif ch==1:
add_question()
elif ch==4:
check_results()
elif ch==5:
break
elif ch==3:
remove_student()
else:
clrprint('\n Enter a valid choice\n',clr='r')
else:
clrprint('Entered password is incorrect\n Better Luck Next Time',clr='r')
break
Student function:
def student():
global htn
htn=input('ENTER HALL TICKET NUMBER')
while True:
ch=input('DO YOU WANT TO START EXAM (Y/N)')
if ch.upper()=='Y' or ch.upper()=='YES':
exam()
sc=result(htn)
break
elif ch.upper()=='N' or ch.upper()=='NO':
break
else:
clrprint('\nEnter a valid choice',clr='r')
Result function:
def result(htn):
sc=(score/c)*100
mycursor.execute('insert into results values("{h}",{s});'.format(h=htn,s=sc))
mydb.commit()
clrprint('\n ..............................Your test has been
completed.................................',clr='g')
Exam function:
def exam():
def check_answer(answer):
global score
if answer == correct_answer:
score += 1
global correct_answer
global c
papers=['maths_paper','mental_ability_paper','maths_paper']
clrprint('\n........................................................................WELCOME TO JNVST
EXAM.........................................................................',clr='g')
while True:
while True:
choice=input('\nFirst you wanna Start with\n1. Maths \n2. Mental Ability')
if choice.isdigit():
break
else:
clrprint('\nEnter a valid choice',clr='r')
if choice=='1' or choice=='2':
break
else:
clrprint('\nEnter a valid choice',clr='r')
choice=int(choice)
for i in range(2):
clrprint('\n',papers[choice-1].upper(),'Paper',clr='b')
mycursor.execute('select * from {p};'.format(p=papers[choice-1]))
questions = mycursor.fetchall()
q = []
for i in questions:
q.append(i[0])
m=max(q)
question=()
for i in range(len(questions)):
while True:
r=random.randint(0,m)
if r in q:
break
for i in questions:
if i[0]==r:
question=i
break
print('\n \n QUESTION ',c+1)
print(question[1],'\nA) ',question[2],'\nB) ', question[3],'\nC) ',
question[4],'\nD)',question[5])
correct_answer=question[6]
while True:
answer=input('ENTER YOUR OPTION\n')
if answer.upper() in ['A','B','C','D']:
break
else:
clrprint('Enter a valid Option',clr='r')
c+=1
q.remove(r)
check_answer(answer.upper())
questions.remove(i)
while True:
if len(questions)>0:
ci=input('1. Continue to next Question\n2. End Test')
if ci=='2':
sc=result(htn)
home()
elif ci=='1':
break
else:
clrprint('\nEnter a valid choice',clr='r')
else:
break
print(papers[choice-1],'paper complted\n ')
tt.sleep(5)
choice+=1
Check_results function:
def check_results():
mycursor.execute('select * from results')
data=mycursor.fetchall()
result=tabulate(data,headers=['Hall-Ticket-Number','Marks'])
print(result)
add_question function:
def add_question():
papers = ['maths_paper', 'mental_ability_paper', 'maths_paper']
while True:
choice = input('\nAdd question to which paper\n1. Maths \n2. Mental Ability')
if choice.isdigit():
if choice == '1' or choice == '2':
choice = int(choice)
break
else:
clrprint('\nEnter a valid choice', clr='r')
else:
clrprint('\nEnter a valid choice',clr='r')
while True:
n=input("Enter number of question you want to enter")
if n.isdigit()==True:
n=int(n)
break
else:
print('enter a valid choice')
for i in range(n):
question=input('Enter Question')
opa=input('enter option A')
opb = input('enter option B')
opc = input('enter option C')
opd = input('enter option D')
answer=input('Enter Answer')
st='insert into {p}(question,A,B,C,D,answer)
values("{q}","{a}","{b}","{c}","{d}","{ans}")'
st=st.format(p=papers[choice-
1],q=question,a=opa,b=opb,c=opc,d=opd,ans=answer.upper())
mycursor.execute(st)
mydb.commit()
print('\n .......Question added succesfully........')
remove_question function:
def remove_student():
st='select hall_ticket_no from results'
mycursor.execute(st)
data=mycursor.fetchall()
lst=[]
for i in data:
lst.append(i[0])
while True:
no=input('enter hall ticket no to remove')
if no in lst:
st='delete from results where hall_ticket_no="{n}"'.format(n=no)
mycursor.execute(st)
mydb.commit()
print("Student removed succesfully")
break
else:
ch=input('1. Try Again\n2.exit')
if ch=='2':
break
Outputs:
Student taking exam:
Admin login:
Removing student:
Conclusion:
The JNVST EXAM is developed using python and sql fully meets the objectives of the system
for which it has been developed. The system has reached a steady state where all bugs have
been eliminated. The system is operated at a high level of efficiency and all the teachers and
user associated with the system understands its advantage. The system solves the problem.
Bibliography:
1. www.python.org
2. www.geeksforgeeks.org
3. www.github.com
4. https://docs.python.org