1 | P a g e
JAWAHAR NAVODAYA VIDYALAYA
DAKSHINA KANNADA
COMPUTER SCIENCE INVESTIGATORY PROJECT
FOOTBALL GAME AND SCORE
MANAGEMENT SYSTEM
NAME OF THE CANDIDATE :
CLASS : XII
ROLL NUMBER :
2 | P a g e
JAWAHAR NAVODAYA
VIDYALAYA
Dakshina Kannada
CERTIFICATE OF BONAFIDE PROJECT REPORT
This is to certify that this bonafide project work in the subject of
COMPUTER SCIENCE has been done by Rohan Raghavanof
class XII Science in the academic year 2020-2021 and submitted
to the A.I.S.S.C.E practical examination conducted by CBSE at
JNV MUDIPU on
Teacher In Charge Principal
Internal Examiner External Examiner
3 | P a g e
ACKNOWLEDGEMENT
I hereby acknowledge my deep gratitude and
indebtedness to the following personalities whose
immense help, guidance, encouragement, necessary
suggestion ,initiation ,enthusiasm and inspiration made
this work a master art & a joint enterprise.
Mr. V Srinivasan(Principal)
Mrs. Rekha Ashok(Vice Principal)
Mr. Santosh kumar(PGT Computer science)
Mr.Puneeth(FCSA)
All otherTeachers, My classmates & friends.
ABOUT THE PROJECT
4 | P a g e
This PYTHON programs on Football Game And Score
Management System has account class with data
members like account number name ,deposit,
withdraw amount and type of account. Customer
data is stored in a binary file. A customer can
deposite and withdraw amount in his account. User
can create, modify and delete account.
#######JAWAHAR NAVODAYA VIDYALAYA DK, MUDIPU ########
###############PYTHONINVESTIGATORY PROJECT ############
##### FOOTBALL GAME AND SCOREMANAGEMENT SYSTEM ####
5 | P a g e
######MADE BY ROHAN RAGHAVAN, SUDEEP, RAHUL K ########
# Modules Used
importpdb
import random
importcsv
# Global Variables used in various functions
ch = 0
a = 0
b = 0
goal = True
point = 0
new = []
cpuint = 0
na = ''
# Function Definitions
# Set Difficulty
6 | P a g e
def op():
print('nSet Difficulty:n1- Easyn2- Hardn3- Insane')
globalch
ch = int(input())
# Change User
def User():
globalna
na = input('Enter Username (case sensitive)>>>')
with open('Highscores.csv','r',newline='') as file:
fr = csv.reader(file)
an = []
fori in fr:
an.append(i[0])
ifna in an:
print('nAlready Registered!! Welcome Back :)n')
7 | P a g e
else:
with open('Highscores.csv','a',newline='') as file:
rw=csv.writer(file)
rw.writerow([na,0])
# Update Scorein Data File
def update():
globalna
global new
globalch
with open('Highscores.csv','r',newline='') as file:
fr = csv.reader(file)
new = []
fori in fr:
new.append(i)
fori in new:
ifi[0]==na:
j = int(i[1])
ifch == 1:
8 | P a g e
j+=1
elifch == 2:
j+=3
elifch == 3:
j+=7
i[1]=j
with open('Highscores.csv','w',newline='') as file:
fw = csv.writer(file)
fw.writerows(new)
# Bubble Sorting inside the CSV file used
def sort():
global lines
with open('Highscores.csv','r')as file:
fr = csv.reader(file)
lines = []
fori in fr:
lines.append(i)
n = len(lines)
#pdb.set_trace()
fori in range(n):
9 | P a g e
for j in range(0,n-i-1):
if lines[j][1] == 'Score':
continue
else:
ifint(lines[j][1]) <int(lines[j+1][1]):
lines[j],lines[j+1] = lines[j+1],lines[j]
with open('Highscores.csv','w',newline='') as file:
fw = csv.writer(file)
fw.writerows(lines)
# Main Function for Game excecution
def shoot():
global goal
global a
global b
globalcpuint
globalch
pos = int(input('''n _______________________
10 | P a g e
|| |1| |2| |3| ||
|| ___ ||
|| {0 - 0} ||
|| |4| ---|_|--- |5| ||
|| /  ||
nnChoose where you want to shoot!nn>>>'''))
l1 = []
fori in range(ch):
#pdb.set_trace()
r = random.randint(1,5)
l1.append(r)
ifpos in l1:
goal = False
elifpos> 5:
goal = False
else:
goal = True
11 | P a g e
if goal == True:
print('GOAAAAAL!!!')
a+=1
else:
print('You Missed :(')
print("n~~~Opponent's Turn~~~n")
l1 = []
goal = True
cpos = random.randint(1,5)
cpuint = 3
l = len(l1)
while True:
r = random.randint(1,5)
iflen(l1) == 3:
break
else:
if r in l1:
continue
else:
l1.append(r)
l+=1
12 | P a g e
ifcpos in l1:
goal = False
else:
goal = True
if goal == True:
print('GOAAAAAL!!!')
b+=1
else:
print('It Missed :)')
# User Input Call
User()
# Initial Difficulty Set
op()
# Main Infinite Loop
13 | P a g e
while True:
print('t~~~KICK OFF~~~')
print(' ~~~Penalty ShootoutGame~~~n')
print('''1- PLAY
2- SCOREBOARD
3- CHANGE DIFFICULTY
4- INSTRUCTIONS
5- CHANGE USER
6- EXIT''')
k = int(input('n>>'))
if k == 1:
14 | P a g e
fori in range(5):
# Main game function call
shoot()
print('nScore-',a,'-',b)
if a>b:
print('n ~~~YOU WIN!!!~~~')
# Updating Scores inside the CSV file after a win
update()
elif a<b:
print('n ~~~MATCH LOST~~~')
else:
print('n ~~~MATCH TIED~~~')
a,b=0,0
15 | P a g e
print('Press Enter to continue...')
input()
elif k == 2:
# Sorting the list in the CSV file before displaying
sort()
with open('Highscores.csv','r')as file:
fr=csv.reader(file)
print('tLEADERBOARDn')
fori in fr:
ifi[0] == 'Username':
print(i[0]+'t'+i[1])
else:
print(i[0]+'tt '+i[1])
16 | P a g e
print('nPress Enter to continue...')
input()
elif k == 3:
op()
elif k == 4:
# Instructions as a multiple line string
print('''ntWelcome to Kick Off!
Press one of the numbers displayed inside the goalpost. The keeper may or may not
save it.
Player and computer get 5 tries each. The one who scores most goals out of 5 wins.
Scores will be updated for every win!
Easy mode: Win = +1 points
Hard mode: Win = +3 points
Insane mode: Win = +7 points
Press Enter to continue...''')
17 | P a g e
input()
elif k == 5:
# Funtion for User Change
User()
elif k == 6:
print('Thank you for playing this game.nGoodbye, See you soon:)')
# Main loop break point
break
else:
print('Invalid choice... Try again O-O')
############################THE END ##########################
###########################THANK YOU ########################
18 | P a g e
OUTPUT SCREENS
HERE THE PATH OF THE PYTHON PROGRAMIS SHOWN HERE
AND THE CURRENT DIRECTORYOF THE FILE (PYTHON)
19 | P a g e
HERE THE OUTPUT SHOWS THE NAME OF THE PROGRAMMADE BY
OUR TEAM TOPICKICK OFF (THE PENALTY GAME) AND THE
CONTENTS TO THE USER KIOSK.
20 | P a g e
HERE THE OUTPUT SHOWS THE INSTRUCTIONS TO THE USER ABOUT
RULES AND REGULATIONS OF THE SOFTWARE.
HERE SOFTWAREASKS THE USER ENTER THE NAME (NAME IS CASE
SENSITIVE .IF USER USES THE NAME AS XYZ HE SHOLUD MAINTAIN
HIS NAME FOR EVER) AND ASKS FOR THE LEVEL OF THE GAME
21 | P a g e
(EASY,HARD ,INSANE)
HERE THE GAME BEGINS !!!!
AND USER IS ON THE PROCESS OF THE GAME
USER MISSED THE 1ST CHANCE
22 | P a g e
HERE THE USER HAS COMPLETED THE GAME AND HE HAS WON THE
GAME BY DEFEATING THE COMPUTER AND THE TOTAL GOALS ARE
DISPLAYED AT LAST [SCORE4(USER)-2(COMPUTER)]
23 | P a g e
HERE THE USER CAN SEARCH HIS SCORES IN LEADERBOARD
PROGRAMHAS OPTIONTO CHANGE THE DIFFICULTY
24 | P a g e
IN
THIS OPTIONPLAYERS CAN SWITCHBETWEEN DIFFERENT USERS
HERE THE GAME ENDS!!!!!
25 | P a g e
THIS IS THE PREVIEW OF THE CSV FILE THAT HANDLES THE SCORE
MANAGEMENT SYSTEM IN THE GAME.
THIS IS THE FONT SIZE AND FONT STYLE THAT IS FOLLOWED
THROUGHOUT THE PYTHON PROGRAM
26 | P a g e
Bibliography
https://www.google.com/
https://stackoverflow.com/
https://docs.python.org/3/
https://www.tutorialspoint.com/python/
Computer science textbook by Sumita Arora

COMPUTER SCIENCE INVESTIGATORY PROJECT ON FOOTBALL GAME AND SCORE MANAGEMENT SYSTEM

  • 1.
    1 | Pa g e JAWAHAR NAVODAYA VIDYALAYA DAKSHINA KANNADA COMPUTER SCIENCE INVESTIGATORY PROJECT FOOTBALL GAME AND SCORE MANAGEMENT SYSTEM NAME OF THE CANDIDATE : CLASS : XII ROLL NUMBER :
  • 2.
    2 | Pa g e JAWAHAR NAVODAYA VIDYALAYA Dakshina Kannada CERTIFICATE OF BONAFIDE PROJECT REPORT This is to certify that this bonafide project work in the subject of COMPUTER SCIENCE has been done by Rohan Raghavanof class XII Science in the academic year 2020-2021 and submitted to the A.I.S.S.C.E practical examination conducted by CBSE at JNV MUDIPU on Teacher In Charge Principal Internal Examiner External Examiner
  • 3.
    3 | Pa g e ACKNOWLEDGEMENT I hereby acknowledge my deep gratitude and indebtedness to the following personalities whose immense help, guidance, encouragement, necessary suggestion ,initiation ,enthusiasm and inspiration made this work a master art & a joint enterprise. Mr. V Srinivasan(Principal) Mrs. Rekha Ashok(Vice Principal) Mr. Santosh kumar(PGT Computer science) Mr.Puneeth(FCSA) All otherTeachers, My classmates & friends. ABOUT THE PROJECT
  • 4.
    4 | Pa g e This PYTHON programs on Football Game And Score Management System has account class with data members like account number name ,deposit, withdraw amount and type of account. Customer data is stored in a binary file. A customer can deposite and withdraw amount in his account. User can create, modify and delete account. #######JAWAHAR NAVODAYA VIDYALAYA DK, MUDIPU ######## ###############PYTHONINVESTIGATORY PROJECT ############ ##### FOOTBALL GAME AND SCOREMANAGEMENT SYSTEM ####
  • 5.
    5 | Pa g e ######MADE BY ROHAN RAGHAVAN, SUDEEP, RAHUL K ######## # Modules Used importpdb import random importcsv # Global Variables used in various functions ch = 0 a = 0 b = 0 goal = True point = 0 new = [] cpuint = 0 na = '' # Function Definitions # Set Difficulty
  • 6.
    6 | Pa g e def op(): print('nSet Difficulty:n1- Easyn2- Hardn3- Insane') globalch ch = int(input()) # Change User def User(): globalna na = input('Enter Username (case sensitive)>>>') with open('Highscores.csv','r',newline='') as file: fr = csv.reader(file) an = [] fori in fr: an.append(i[0]) ifna in an: print('nAlready Registered!! Welcome Back :)n')
  • 7.
    7 | Pa g e else: with open('Highscores.csv','a',newline='') as file: rw=csv.writer(file) rw.writerow([na,0]) # Update Scorein Data File def update(): globalna global new globalch with open('Highscores.csv','r',newline='') as file: fr = csv.reader(file) new = [] fori in fr: new.append(i) fori in new: ifi[0]==na: j = int(i[1]) ifch == 1:
  • 8.
    8 | Pa g e j+=1 elifch == 2: j+=3 elifch == 3: j+=7 i[1]=j with open('Highscores.csv','w',newline='') as file: fw = csv.writer(file) fw.writerows(new) # Bubble Sorting inside the CSV file used def sort(): global lines with open('Highscores.csv','r')as file: fr = csv.reader(file) lines = [] fori in fr: lines.append(i) n = len(lines) #pdb.set_trace() fori in range(n):
  • 9.
    9 | Pa g e for j in range(0,n-i-1): if lines[j][1] == 'Score': continue else: ifint(lines[j][1]) <int(lines[j+1][1]): lines[j],lines[j+1] = lines[j+1],lines[j] with open('Highscores.csv','w',newline='') as file: fw = csv.writer(file) fw.writerows(lines) # Main Function for Game excecution def shoot(): global goal global a global b globalcpuint globalch pos = int(input('''n _______________________
  • 10.
    10 | Pa g e || |1| |2| |3| || || ___ || || {0 - 0} || || |4| ---|_|--- |5| || || / || nnChoose where you want to shoot!nn>>>''')) l1 = [] fori in range(ch): #pdb.set_trace() r = random.randint(1,5) l1.append(r) ifpos in l1: goal = False elifpos> 5: goal = False else: goal = True
  • 11.
    11 | Pa g e if goal == True: print('GOAAAAAL!!!') a+=1 else: print('You Missed :(') print("n~~~Opponent's Turn~~~n") l1 = [] goal = True cpos = random.randint(1,5) cpuint = 3 l = len(l1) while True: r = random.randint(1,5) iflen(l1) == 3: break else: if r in l1: continue else: l1.append(r) l+=1
  • 12.
    12 | Pa g e ifcpos in l1: goal = False else: goal = True if goal == True: print('GOAAAAAL!!!') b+=1 else: print('It Missed :)') # User Input Call User() # Initial Difficulty Set op() # Main Infinite Loop
  • 13.
    13 | Pa g e while True: print('t~~~KICK OFF~~~') print(' ~~~Penalty ShootoutGame~~~n') print('''1- PLAY 2- SCOREBOARD 3- CHANGE DIFFICULTY 4- INSTRUCTIONS 5- CHANGE USER 6- EXIT''') k = int(input('n>>')) if k == 1:
  • 14.
    14 | Pa g e fori in range(5): # Main game function call shoot() print('nScore-',a,'-',b) if a>b: print('n ~~~YOU WIN!!!~~~') # Updating Scores inside the CSV file after a win update() elif a<b: print('n ~~~MATCH LOST~~~') else: print('n ~~~MATCH TIED~~~') a,b=0,0
  • 15.
    15 | Pa g e print('Press Enter to continue...') input() elif k == 2: # Sorting the list in the CSV file before displaying sort() with open('Highscores.csv','r')as file: fr=csv.reader(file) print('tLEADERBOARDn') fori in fr: ifi[0] == 'Username': print(i[0]+'t'+i[1]) else: print(i[0]+'tt '+i[1])
  • 16.
    16 | Pa g e print('nPress Enter to continue...') input() elif k == 3: op() elif k == 4: # Instructions as a multiple line string print('''ntWelcome to Kick Off! Press one of the numbers displayed inside the goalpost. The keeper may or may not save it. Player and computer get 5 tries each. The one who scores most goals out of 5 wins. Scores will be updated for every win! Easy mode: Win = +1 points Hard mode: Win = +3 points Insane mode: Win = +7 points Press Enter to continue...''')
  • 17.
    17 | Pa g e input() elif k == 5: # Funtion for User Change User() elif k == 6: print('Thank you for playing this game.nGoodbye, See you soon:)') # Main loop break point break else: print('Invalid choice... Try again O-O') ############################THE END ########################## ###########################THANK YOU ########################
  • 18.
    18 | Pa g e OUTPUT SCREENS HERE THE PATH OF THE PYTHON PROGRAMIS SHOWN HERE AND THE CURRENT DIRECTORYOF THE FILE (PYTHON)
  • 19.
    19 | Pa g e HERE THE OUTPUT SHOWS THE NAME OF THE PROGRAMMADE BY OUR TEAM TOPICKICK OFF (THE PENALTY GAME) AND THE CONTENTS TO THE USER KIOSK.
  • 20.
    20 | Pa g e HERE THE OUTPUT SHOWS THE INSTRUCTIONS TO THE USER ABOUT RULES AND REGULATIONS OF THE SOFTWARE. HERE SOFTWAREASKS THE USER ENTER THE NAME (NAME IS CASE SENSITIVE .IF USER USES THE NAME AS XYZ HE SHOLUD MAINTAIN HIS NAME FOR EVER) AND ASKS FOR THE LEVEL OF THE GAME
  • 21.
    21 | Pa g e (EASY,HARD ,INSANE) HERE THE GAME BEGINS !!!! AND USER IS ON THE PROCESS OF THE GAME USER MISSED THE 1ST CHANCE
  • 22.
    22 | Pa g e HERE THE USER HAS COMPLETED THE GAME AND HE HAS WON THE GAME BY DEFEATING THE COMPUTER AND THE TOTAL GOALS ARE DISPLAYED AT LAST [SCORE4(USER)-2(COMPUTER)]
  • 23.
    23 | Pa g e HERE THE USER CAN SEARCH HIS SCORES IN LEADERBOARD PROGRAMHAS OPTIONTO CHANGE THE DIFFICULTY
  • 24.
    24 | Pa g e IN THIS OPTIONPLAYERS CAN SWITCHBETWEEN DIFFERENT USERS HERE THE GAME ENDS!!!!!
  • 25.
    25 | Pa g e THIS IS THE PREVIEW OF THE CSV FILE THAT HANDLES THE SCORE MANAGEMENT SYSTEM IN THE GAME. THIS IS THE FONT SIZE AND FONT STYLE THAT IS FOLLOWED THROUGHOUT THE PYTHON PROGRAM
  • 26.
    26 | Pa g e Bibliography https://www.google.com/ https://stackoverflow.com/ https://docs.python.org/3/ https://www.tutorialspoint.com/python/ Computer science textbook by Sumita Arora