You are on page 1of 22

COMPUTER SCIENCE

PROJECT
SPORTS DAY POINTS
CALCULATOR

1. THEORETICAL BACKGROUND

2. PROGRAM DESCRIPTION
3. HARDWARE AND SOFTWARE
REQUIREMENTS
5. PROGRAM CODE

6. OUTPUT CODE

7. FUTURE ENHANCEMENT OF
THE PROJECT
8. BIBILIOGRAPHY

TABLE OF CONTENTS

THEROTICAL BACKGROUND

1.WHAT IS PYTHON?
Python is an interpreted, high-level and general-purpose programming
language which emphasizes code readability with its notable use of significant
whitespace. Its language constructs an object-oriented approach which aims to
help programmers write a clear, logical code for small and large-scale projects.
Python is dynamically typed and it supports multiple programming paradigms,
including structured (particularly, procedural), object-oriented and functional
programming. Python interpreters are supported for mainstream operating
systems and available for a few more. A global community of programmers
develops and maintains CPython, a free and open-source reference
implementation. A non-profit organization, the Python Software Foundation,
manages and directs resources for Python and CPython development.

2. HISTORY OF PYTHON:
The programming language Python was conceived in the late 1980s, and
its implementation was started in December 1989 by Guido van Rossum at CWI
in the Netherlands as a successor to ABC capable of exception handling and
interfacing with the Amoeba operating system. Van Rossum is Python's
principal author, and his continuing central role in deciding the direction of
Python is reflected in the title given to him by the Python community,
Benevolent Dictator for Life (BDFL). (However, van Rossum stepped down as
leader on July 12, 2018. Python 2.0 was released on October 16, 2000, with
many major new features for memory management and support for Unicode.
However, the most important change was to the development process itself,
with a shift to a more transparent and community-backed process. Python 3.0, a
major, backwards-incompatible release, was released on December 3, 2008 after
a long period of testing. Many of its major features have also been back ported
to the backwards-compatible, while by now unsupported, Python 2.6 and 2.7.

3. WHAT IS A DATABASE?
Database is a collection of information that is organised so as to access
them easily and quickly.In a relational database,the digital information are
arranged into rows,columns and tables which are indexed to access the relevant
information.There are different kinds of databases ranging for the most
approached relational database,to a distributed database, cloud database, graph
database or NoSQL database.
Relational database: A relational database, invented by E.F. Codd at IBM
in 1970, is a tabular database in which data is defined so that it can be
reorganized and accessed in a number of different ways. Relational databases
are made up of a set of tables with data that fits into a predefined category. Each
table has at least one data category in a column, and each row has a certain data
instance for the categories which are defined in the columns.Relational
databases are easy to extend, and a new data category can be added after the
original database creation without requiring that you modify all the existing
applications
RELATIONAL DATABASE MANAGEMENT SYSTEM:
A relational database management system shortly called as RDBMS is a
Database management system that is designed specifically for relational
databases.It is the software that executes queries on the data, including adding,
updating, and searching for values. An RDBMS may also provide a visual
representation of the data. For example, it may display data in a tables like a
spreadsheet, allowing you to view and even edit individual values in the table.
Some RDMBS programs allow you to create forms that can streamline entering,
editing, and deleting data. Most well known DBMS applications fall into the
RDBMS category. Examples include Oracle Database, MySQL, Microsoft SQL
Server, and IBM DB2. Some of these programs support non-relational
databases, but they are primarily used for relational database management.

4. WHAT IS SQL?
SQL (Structured Query Language) is a domain-specific language used in
programming and designed for managing data held in a relational database
management system (RDBMS), or for stream processing in a relational data
stream management system (RDSMS). It is particularly useful in handling
structured data, i.e. data incorporating relations among entities and
variables.SQL offers two main advantages over older read–write APIs. Firstly,
it introduced the concept of accessing many records with one single command.
Secondly, it eliminates the need to specify how to reach a record, e.g. with or
without an index. HISTORY OF SQL: SQL was initially developed at IBM by
Donald D. Chamberlin and Raymond F. Boyce after learning about the
relational model from Edgar F. Codd in the early 1970s.This version, initially
called SEQUEL (Structured English Query Language), was designed to
manipulate and retrieve data stored in IBM's original quasi-relational database
management system, System R, which a group at IBM San Jose Research
Laboratory had developed during the 1970s. In the late 1970s, Relational
Software, Inc. (now Oracle Corporation) saw the potential of the concepts
described by Codd, Chamberlin, and Boyce, and developed their own SQL-
based RDBMS with aspirations of selling it to the U.S. Navy, Central
Intelligence Agency, and other U.S. government agencies. In June 1979,
Relational Software, Inc. introduced the first comVAX computers. By 1986,
ANSI and ISO standard groups officially adopted the standard "Database
Language SQL" language definition. New versions of the standard were
published in 1989, 1992, 1996, 1999, 2003, mercially available implementation
of SQL, Oracle V2 (Version2) for 2006, 2008, 2011 and, most recently, 2016.

5.HISTORY OF SQL:
SQL was initially developed by Donald.K Chamberlin
And Raymond F. Boyce after learning about the relational model from Edgar F.
Codd in the early 1970s. this version,
Initially called SEQUEL (Structured English Query Language)
Was designed to manipulate and retrieve data stored i
IBM's original quasi-relational database management
System, System R which a group at IBM San Jose research laboratory had
developed during the 1970s. in the late 1970s,Relational Software, Inc(now
Oracle Corporation) saw
The potential of the concepts described by Codd Chamberlin
And Boyce, and developed their own SQL-based RDBMS with
Aspirations of sellig it to the U.S. Navy, Central Intelligence Agency and other
U.S. government agencies.
In June 1979, Relational Software, Inc introduced to the first Comvax
computers. By 1986, ANSI and ISO Standard groups officially adopted the
standard were published in 1989,1992,1996,1999,2003,merciall available
implementation of SQL,Oracle V2 for 2006,2008,2011 and most recently 2016.
PROGRAM DESCRIPTION

INTRODUCTION:
THIS PROGRAM IS A BASICALLY A POINTS TABLE
WHICH CALCULATES THE TOTAL POINTS
ACCUMALATED BY EACH TEAM IN THE SPORTS
DAY. IT WORKS BASED ON FIXED VALUES FOR
EACH RANK AND ALL THE USER HAS TO DO IS TO
ENTER THE HOUSE NAME AND THE RANK OR THE
POSITION OF THE TEAM IN THE RESPECTIVE
EVENTS. THIS SOFTWARE HELPS IN EASIER
CALCULATION OF POINTS WITHOUT ERROR AND
MANUAL CALCULATION.

PROGRAM MODULES AND FUNCTIONS:


THIS SOFTWARE USES PYTHON, PYTHON
INTERFACE WITH SQL, CSV FILES AND EXCEL
WHERE THE DATA IS STORED AND CALCULATED.
MODULES USED:
 CSV
 OS
 PANDAS
 MYSQLCONNECTOR.CONNECT
 OPENPYXL
FUNCTIONS:
1. ADD():
This function is essentially used for adding data into the
master table which contains the data for the fixed points for
each position. The user can input data in python for the
respective ranks which will be then inputted in SQL with
the help of mysql.connector module.

2. RANK():
This function is used for adding the positions secured by
each house in their respective events. The user has to
input the house name, event name and the position
secured. The points are then automatically allocated to the
houses depending on the position. Csv module is used for
writing data into the file.

3. SCORE():
This function is used for showing the details for one
single house for which the data had been inputted in the
previous function. The user has to input the house name;
then the file is opened in excel where the points scored by
the house inputted is displayed. Again this function uses
csv module.

4. ALLHOUSE():
This function is used for viewing the points table of all the
houses with their event names, position, and points. The
function gives an option to the users to either see the data
in python or excel. This function uses csv, os and pandas
modules.

5. TOTALPOINTS():
This function calculates the total points for all the houses
after all the data is inputted in the above functions and
then displays which team/house has won the tournament.
This function uses csv module for collecting data.

HARDWARE AND
SOFTWARE
REQUIREMENTS:
HARDWARE:
 Processor: Intel(R) Core(TM) i5-1035G1 CPU @
1.00GHz 1.19 GHz
 4gb RAM
 System type: 64-bit operating system, x64-based
processor

SOFTWARE:
 Python shell
 Mysql
 Excel

Source code
import csv
import os
import pandas as pd
import mysql.connector as ms
def add():
db=ms.connect(host="localhost",
user="root",
passwd="windows11",
database="Sports_Day")
cur=db.cursor()
cur.execute("create table if not exists Master_Table(Rank int, Points
float)")
for i in range(4):
r=int(input("Enter rank:"))
p=float(input("Enter points:"))
cur.execute("insert into Master_Table values({},{})".format(r,p))
db.commit()
ch=input("Would you like to view the Master Table?(y/n):")
if ch=='y':
cur.execute("select * from Master_Table")
data=cur.fetchall()
print('\n')
print("Rank","Points",sep=' ')
for i in data:
print(i[0],i[1],sep=' ')

def head():
f1=open("New.csv","w",newline='')
wo=csv.writer(f1)
wo.writerow(['House','Sport','Rank','Points'])
f1.close()
def rank(ho,n):
print("-------------------------------Entering ranks
for",ho,"house----------------------------------")
f1=open("New.csv","a",newline='')
wo=csv.writer(f1)
ch='y'
print("For",ho,"house:")
for i in range(n):
sp=input("Enter sporting event:")
rk=int(input("Enter rank:"))
if rk==1:
p=100
rez=[ho,sp,rk,p]
elif rk==2:
p=90
rez=[ho,sp,rk,p]
elif rk==3:
p=80
rez=[ho,sp,rk,p]
else:
p=70
rez=[ho,sp,rk,p]
wo.writerow(rez)
f1.close()
print('\n')
def score(hu):
f2=open("Scoreboard.csv","w",newline='')
f1=open("New.csv","r")
wf=csv.writer(f2)
wf.writerow(['House','Sport','Rank','Points'])
f1.seek(0)
sr=csv.reader(f1)
for i in sr:
if hu==i[0]:
wf.writerow(i)
f1.close()
f2.close()
rf=pd.read_csv(r'Scoreboard.csv')
rf.to_excel('Score.xlsx',index=None,header=True)
print("Showing",hu,"house details in Microsoft Excel...")
os.startfile('Score.xlsx')

def allhouse():
a=input("Would you like to view it in python or in excel?(e/p):")
if a in 'pP':
f=open("New.csv","r")
ro=csv.reader(f)
print('\n')
for i in ro:
print(i[0],i[1],i[2],i[3])
f.close()
elif a in 'eE':
rf=pd.read_csv(r'New.csv')
rf.to_excel('Houses.xlsx',index=None,header=True)
print("Opening Microsoft Excel...")
os.startfile('Houses.xlsx')
else:
print("Invalid input")

def totalpoints():
print("============================Calculating total
points===================================")
f=open("New.csv","r")
f3=open("Total.csv","a",newline='')
w=csv.writer(f3)
ro=csv.reader(f)
for i in ro:
if i[3].isdigit():
w.writerow(i)
f.close()
f3.close()
f=open("Total.csv","r")
r=csv.reader(f)
f.seek(0)
smr=0
smj=0
sml=0
smc=0
for i in r:
if i[0]=='Rose':
er=i[3]
er=int(er)
smr=smr+er
elif i[0]=='Jasmine':
ej=i[3]
ej=int(ej)
smj=smj+ej
elif i[0]=='Lotus':
el=i[3]
el=int(el)
sml=sml+el
else:
ec=i[3]
ec=int(ec)
smc=smc+ec
f.close()
print("Rose house total score is",smr)
print("Jasmine house total score is",smj)
print("Lotus house total score is",sml)
print("Chrysanthemum house total score is",smc)
l=[smr,smj,sml,smc]
mx=max(l)
if l[0]==l[1]==l[2]==l[3]:
print("All the houses have performed surprisingly the same. Its a tie
between all the houses!")
elif l[0]==l[1]==l[2]:
print("Its a tie between Rose, Jasmine and Lotus!")
elif l[0]==l[2]==l[3]:
print("Its a tie between Rose, Lotus and Chrysanthemum!")
elif l[1]==l[2]==l[3]:
print("Its a tie between Jasmine, Lotus and Chrysanthemum!")
elif l[0]==l[1]==l[3]:
print("Its a tie between Rose, Jasmine and Chrysanthemum!")
elif l[0]==mx:
print("Therefore Rose house is the winner. Congratulations Rose
house!")
elif l[1]==mx:
print("Therefore Jasmine house is the winner. Congratulations
Jasmine house!")
elif l[2]==mx:
print("Therefore Lotus house is the winner. Congratulations Lotus
house!")
elif l[3]==mx:
print("Therefore Chrysanthemum house is the winner.
Congratulations Chrysanthemum house!")
elif l[0]==l[1]:
print("Its a tie between Rose and Jasmine!")
elif l[0]==l[2]:
print("Its a tie between Rose and Lotus!")
elif l[0]==l[3]:
print("Its a tie between Rose and Chrysanthemum!")
elif l[1]==l[2]:
print("Its a tie between Jasmine and Lotus!")
elif l[1]==l[3]:
print("Its a tie bewteen Jasmine and Chrysanthemum!")
elif l[2]==l[3]:
print("Its a tie between Lotus and Chrysanthemum!")

while True:
print("\n")
print('1.Master table creation\n2.Enter ranks of each house \n3.Viewing
the details of a single house \n4.Viewing the details of all houses \
n5.Calculating total points of each house and declaring the winner \
n6.exit')
ch=int(input("enter choice:"))
if ch==1:
print("Creating the master table for points reference:")
add()
elif ch==2:
n=int(input("Enter number of sporting events:"))
head()
for i in range(4):
ho=input("Enter house name:")
rank(ho,n)
elif ch==3:
hu=input("enter the house name:")
score(hu)
elif ch==4:
allhouse()
elif ch==5:
totalpoints()
elif ch==6:
break
else:
print("Invalid character”)

Output
FUTURE ENHANCEMENTS:
This project is a very basic version of what could be a potential software
because sports day events are conducted in every school in the event and
when there is no chance of human error or any error, which makes the
working of the events smooth without any issues.
The program could be developed into an app or website in the future.
More security features like prevention of tampering or any misdemeanors
that could happen by mistake or intentionally.
Many more features like scheduling events could be developed so that it
would be easy for the administrative staff to conduct events at the right
place at the right time

CURRENT APPLICATIONS:
This program can currently calculate the total points of each house and
also view individual details of each house whenever required. Also the
data entered for each house is shown separately that is the points are
individually shown for each event won and the points secured for the
respective events so that even if there was an error while entering data it
can be found while referring to the excel table very easily.
BIBLIOGRAPHY:
1. www.geeksforgeeks.org
2. www.google.com
3. 12th NCERT textbook
4. Sumita Arora python textbook

You might also like