Project PDF (RAHUL)
Project PDF (RAHUL)
In
Computer Science (083)
By:
1.Rahul Rakesh Narain – XII A – Roll No:
2.Vaibhav – XII A – Roll No:
3.Suryansh Tiwari – XII A – Roll No:
4.Prashant Kumar – XII A – Roll No:
---------------- ----------------
Teacher’s Principal’s
signature signature
----------------
Examiner’s
signature
ACKNOWLEDGEMENT
3. Python Coding.
5. References.
INTRODUCTION
This project introduces a fun vs computer cricket
game. In this game we have setted up the
computer to ball and the user will be batting to
score the highest possible runs to make it to the
top of the leader board against other users.
System Requirements of
the Project
Recommended System Requirements
Processors:
Intel® Core™ i3 processor 4300M at 2.60 GHz.
Disk space: 2 to 4 GB. Operating systems:
Windows® 10, MACOS, and UBUNTU. Python
Versions: 3.X.X or Higher. Minimum System
Requirements Processors:
Intel Atom® processor or Intel® Core™ i3
processor. Disk space: 1 GB. Operating systems:
Windows 7 or later, MACOS, and UBUNTU.
Python Versions: 2.7.X, 3.6.X.
“Easygui”
For a user friendly interactive and attractive
dialogue box generation for secure and easy login
into the game.
PYTHON CODING
import mysql.connector as ms
import random
def getuname():
import easygui
return easygui.enterbox("Enter your
username")
def getpass():
import easygui
return easygui.passwordbox()
def upscore(user,score):
def inputscore(user,score):
cur.execute(f"insert into lb
values('{user}','{score}');")
c.commit()
while True:
c=ms.connect(host="localhost",user="root",passw
ord="sql1234",database="project")
cur=c.cursor()
print('''
========================
MENU
========================
1.Login
2.Register
3.Leaderboard
4.How to play
5.Quit
''')
ch=int(input("Enter your choice:"))
if ch==1:
un=getuname()
cur.execute("select username from login")
x=cur.fetchall()
l=[]
for a in x:
for st in range(0,1):
l.append(a[st])
if un in l:
up=getpass()
p=str(up)
cur.execute(f"select pass from login where
username like '{un}'")
y=cur.fetchall()
for b in y:
if p in b:
print("Logged in successfully.")
wic=3
sco=0
ba=18
while wic > 0 and ba > 0:
pc=int(input("Runs score on this
ball(1-6):"))
cc=random.randrange(1,7)
print(cc)
if cc==pc or pc>=7:
print("You lost a wicket.")
wic=wic-1
else:
sco=sco+pc
ba=ba-1
print(f"Balls remaining:{ba}")
print("Your score this game is:",sco)
cur.execute(f"select username from
lb")
us=cur.fetchall()
ls=[]
for search in us:
for ssearch in range(0,1):
ls.append(search[ssearch])
if un in ls:
upscore(un,sco)
else:
inputscore(un,sco)
else:
print("Password incorrect.")
else:
print("Username incorrect or not found.")
if ch==2:
n=getuname()
p=getpass()
cur.execute("select pass from login")
o=cur.fetchall()
for g in o:
if p in g:
print("Password already taken.")
print("Re-run the game to register again
with a different password.")
break
else:
cur.execute(f"Insert into login
values('{n}','{p}')")
print("Account created successfully. ")
print("Re-run the game and login to
play.")
c.commit()
break
break
if ch==3:
cur.execute("select * from lb order by score
desc")
u=cur.fetchall()
for b in u:
print(b)
if ch==4:
print('''
******REGISTER OR LOGIN TO PLAY*******
***RULES***
''')
if ch==5:
print('''
*************************
Quitting the game
*************************
''')
break
USER AUTHENTICATION
LEADERBOARD
HOW TO PLAY
References
1. python.org
2. LearnPython.org
3.Github.com