0% found this document useful (0 votes)
15 views20 pages

Ranjan Cs

Uploaded by

ritikwalker9
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)
15 views20 pages

Ranjan Cs

Uploaded by

ritikwalker9
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
You are on page 1/ 20

COMPUT

ER
SCIENCE
PROJECT
12th
A
SCHOOL OLYMPICS
MANAGEMENT

Submitted By:-
Aditya Ranjan Singh
Roll :-14 1227020

Group Members:-
Advaith Deepu
Siddharth Singh
Kathait
CERTIFICATE
This is to certify that Aditya Ranjan Singhs of
Class 12 has successfully completed his Project
File of Computer Science for Class XII CBSE
on the topic ‘School Olympic Management’.

It is further certified that this project is the


individual work of the candidate.

Internal Examiner Sign:

External Examiner Sign:

Principal Sign:
INDEX
➢ Acknowledgement.
➢ Objective.
➢Hardware Requirements.
➢ Software Requirements.
➢ Limitations.
➢ SQL table
➢ Program code.
➢ Output.
➢ Bibliography.
ACKNOWLEDGEMENT
We would like to express our deepest gratitude
towards our Computer Science teacher Ms.
Manju Jayswal for her able guidance and support
in completing my project. We would also like to
extend our gratitude to our Principal Ma'am, Dr.
Bernadette Tilaka Benjamin, who gave us the
golden opportunity to do this wonderful and
informative project on the topic ‘School
Olympics Management’.

We are also indebted to our family and friends for


their support which helped us to complete this
project on time.
OBJECTIVE
The objectives of this project include:-

1. To make keeping track of events easier


2. To reduce any chance of tampering in the
results in case of a large number of sports
3. To compute and declare results quickly
4. Easy id-based searching and modifying
system
5. All data at your fingertips
Hardware
Requiremen
ts
1. A Computer/Laptop with
Operating System-Windows 7
or above
2. x86 64-bit CPU (Intel /
AMD architecture)
3. 4 GB RAM.
4. 5 GB free disk space.
Software
Requiremen
ts
1. Python 3.6.x or higher
version
2. MySQL Server installed
3. MySQL-connector installed
(using pip)
Limitation
s
1. Ambiguity in medals earned by
teams and individuals
2. More functionality can be added
as per requirement.
3. No provision to display scores
appropriately on a score board.
4. No division of sports into Sub-
Events.
5. Id once deleted is permanently
removed and cannot be used again

SQL
TABLE:
 Name of database: sport_records
 Name of table: medal_info
 Columns: Id, player name, house, sport, position
Program
Code
import mysql.connector as sqltor
mycon=sqltor.connect(
host="localhost",
user="root",
passwd="password",
database="sport_records")
if mycon.is_connected()==False:
print("Error Connecting to MySQL Database")
cursor=mycon.cursor()

def inputHouse():
validHouses=["Pratap","Shivaji","Laxmibai","Ashoka"]
val=False
while val==False:
inpHouse=input("Enter Name of House: ")
if inpHouse in validHouses:
val=True
else:
print("Invalid House! Try Again. Valid Houses: Pratap,
Shivaji, Laxmibai, Ashoka")
return inpHouse

def addRecord():
try:
print()
print("----Add Record----")
print()
name=input("Enter name of player: ")
house=inputHouse()
sport=input("Enter name of Sport: ")
pos=int(input("Enter position recieved: "))
cursor.execute("SELECT * from medal_info")
p=cursor.fetchall()
sql="INSERT INTO medal_info VALUES "+str((p[-1]
[0]+1,name,house,sport,pos))
cursor.execute(sql)
mycon.commit()
print("1 Record Added, player id:",p[-1][0]+1)
except:
print("Error! Please check your inputs")

def addteamRecords():
try:
print("Add Team Record")
house=inputHouse()
sport=input("Enter sport: ")
pos=input("Enter position recieved: ")
n=int(input("How many players?"))
lstPlayers=[]
genPlayers=[]
for x in range(1,n+1):
a=input("Enter Name of Player "+str(x)+" : ")
lstPlayers.append(a)
for name in lstPlayers:
cursor.execute("SELECT * from medal_info")
p=cursor.fetchall()
sql="INSERT INTO medal_info VALUES "+str((p[-1]
[0]+1,name,house,sport,pos))
cursor.execute(sql)
mycon.commit()
print(n,"records added, player ids:",p[-1][0]-
n+1,"to",p[-1][0])
except:
print("Error!! Please check your inputs")
addteamRecords()

def deleteRecord():
Id=input("Enter id to be deleted: ")
sql="DELETE FROM medal_info WHERE id="+Id
cursor.execute(sql)
mycon.commit()
print("Record Deleted")

def modifyRecord():
Id=input("Enter id of player to Search/Modify: ")
sql="SELECT*FROM medal_info WHERE id="+Id
try:
cursor.execute(sql)
f=cursor.fetchall()
tup=f[0]
print("id\t\t\tname\t\t\thouse\t\t\tSport\t\t\tPosition")
for x in f:
for y in x:
tab="\t" if len(str(y))>=16 else "\t\t" if
len(str(y))>=8 else "\t\t\t"
print(y, end=tab)
print()
print("---Modify Menu---")
print("1. Change Name")
print("2. Change Position")
print("3. Change Sport Event")
print("4. Change House")
print("5. Search for another id")
print("6. Exit")
ch=int(input("Enter choice: "))
if ch==1:
newName=input("Change name to: ")
sql="UPDATE medal_info SET Player=\""+newName+"\"
WHERE id="+Id
cursor.execute(sql)
print("1 Record Updated")
elif ch==2:
newPos=input("Change Position to: ")
sql="UPDATE medal_info SET Position="+newPos+" WHERE
id="+Id
cursor.execute(sql)
print("1 Record Updated")
elif ch==3:
newEvent=input("Change sport to: ")
sql="UPDATE medal_info SET Sport=\""+newEvent+"\"
WHERE id="+Id
cursor.execute(sql)
print("1 Record Updated")
elif ch==4:
newHouse=inputHouse()
sql="UPDATE medal_info SET House=\""+newHouse+"\"
WHERE id="+Id
cursor.execute(sql)
print("1 Record Updated")
elif ch==5:
mycon.commit()
modifyRecord()
elif ch==6:
return None
else:
print("Invalid option!! Try Again")
modifyRecord()
mycon.commit()
except IndexError:
print("Id not found. Try again")
modifyRecord()

def displayRecords():
cursor.execute("SELECT*FROM medal_info")
f=cursor.fetchall()
print("id\t\t\tname\t\t\thouse\t\t\tSport\t\t\tPosition")
for x in f:
for y in x:
tab="\t" if len(str(y))>=16 else "\t\t" if
len(str(y))>=8 else "\t\t\t"
print(y, end=tab)
print()

def medalStandings():
pointsdict=PointsCalc()
points=list(pointsdict.keys())
points.sort(reverse=True)
house=[]
for w in points:
house.append(pointsdict[w])
print("Standing\tHouse\t\tGold\t\tSilver\t\tBronze")
Sno=1
for x in house:
print(Sno, end="\t\t")
tab="\t" if len(x)>=8 else "\t\t"
print(x, end=tab)
for y in range(1,4):
sql="SELECT COUNT(*) FROM medal_info WHERE
house=\""+str(x)+"\""+" AND position=\""+str(y)+"\""
cursor.execute(sql)
f=cursor.fetchall()
print(f[0][0], end="\t\t")
print()
Sno+=1
return house

def PointsCalc():
house=["Pratap","Ashoka","Shivaji","Laxmibai"]
dictPoints={}
for x in house:
Points=0
sql="SELECT * FROM medal_info WHERE house=\""+x+"\""
cursor.execute(sql)
f=cursor.fetchall()
for y in f:
if y[4]==1:
Points+=3
elif y[4]==2:
Points+=2
elif y[4]==3:
Points+=1
dictPoints[Points]=x
return dictPoints

def declareWinner():
winner=medalStandings()[0]
print()
print(winner," house has won the St. Paul's
Olympics!!!!!!!")

#menu
while True:
print()
print("---------------St. Paul's Olympics
Management-----------------")
print("1. Add Player Record")
print("2. Delete Player Record by id")
print("3. Search & Modify using id")
print("4. Display all records")
print("5. Medal Standings by House")
print("6. Declare winning house")
print("7. Exit")
ch=int(input("what action do you wish to perform?"))
if ch==1:
ask=input("Team or solo? (t/s): ")
if ask=="s":
addRecord()
elif ask=="t":
addteamRecords()
elif ch==2:
deleteRecord()
elif ch==3:
modifyRecord()
elif ch==4:
displayRecords()
elif ch==5:
medalStandings()
elif ch==6:
declareWinner()
elif ch==7:
print("Exiting Program....")
break
else:
print("Invalid Choice!!! Try Again.")

Output
1.Adding Player:-
a)Individual Addition
b)Teamwise Addition

2.Deleting Player by id :-
3.Search and Modify by id Menu :-
a) Changing Name:-

b) Changing Position:-

c) Changing Sport Event:-


d) Changing House

4.Displaying all Records:-

5.Medal Standings :-
5.Declare Winning House :-

6.Exit Program:-
Bibliograp
hy
1. Computer Science With Python By\
Sumita Arora.
2. NCERT Computer Science With Python
3. https://www.python.org
4. https://www.sql.org
5. w3schools.com

You might also like