Professional Documents
Culture Documents
Kushal Modi Project Cricket
Kushal Modi Project Cricket
DHOLAKIYA SCHOOL
PROJECT REPORT ON
CRICKET GAME
ROLL NO :
CLASS : XII
PGT (CS)
DHOLAKIYA SCHOOL
1
DHOLAKIYA SCHOOL, RAJKOT
CERTIFICATE
has successfully completed the project work entitled “CRICKET GAME” in the
subject Computer Science (083) laid down in the regulations of CBSE for the purpose of
Signature:
Examiner:
Name:
Signature:
2
TABLE OF CONTENTS [ T O C ]
01 ACKNOWLEDGEMENT 04
05 OUTPUT 19-24
07 BIBILIOGRAPHY 26
3
ACKNOWLEDGEMENT
Apart from the efforts of me, the success of any project depends largely on the
encouragement and guidelines of many others. I take this opportunity to express my gratitude to
the people who have been instrumental in the successful completion of this project.
I express deep sense of gratitude to almighty God for giving me strength for the
successful completion of the project.
The guidance and support received from all the members who contributed and who are
contributing to this project, was vital for the success of the project. I am grateful for their
constant support and help.
4
WHAT IS PYTHON?
Python is a popular programming language. It was created by Guido van
Rossum, and released in 1991.
It is used for:
5
WHY PYTHON?
Python works on different platforms (Windows, Mac, Linux,
Raspberry Pi, etc).
Python has a simple syntax similar to the English language.
Python has syntax that allows developers to write programs with fewer
lines than some other programming languages.
Python runs on an interpreter system, meaning that code can be executed as
soon as it is written. This means that prototyping can be very quick.
Python can be treated in a procedural way, an object-oriented way or a
functional way.
GOOD TO KNOW
The most recent major version of Python is Python 3, which we shall be
using in this tutorial. However, Python 2, although not being updated with
anything other than security updates, is still quite popular.
In this tutorial Python will be written in a text editor. It is possible to write
Python in an Integrated Development Environment, such as Thonny,
Pycharm, Netbeans or Eclipse which are particularly useful when
managing larger collections of Python files.
Python was designed for readability, and has some similarities to the
English language with influence from mathematics.
Python uses new lines to complete a command, as opposed to other
programming languages which often use semicolons or parentheses.
Python relies on indentation, using whitespace, to define scope; such as the
scope of loops, functions and classes. Other programming languages often
use curly-brackets for this purpose.
6
What is Cricket?
Cricket is a bat and ball game played between two teams, 11 players each, on a
field which has a rectangular 22-yard-long pitch in the centre. The game is played
by 120 million players world-wide making it the second most popular sport in the
world. The purpose of the game is to score more runs than your opposing team.
A Cricket match is divided into periods called innings. It is decided before the
game begins, if both teams will have one or two innings. During the innings one
team bats while the other fields. All 11 players on the fielding team are on the
pitch at the same time however only two batsmen are the field at any one time.
Cricket fields tend to be oval in shape. The end which is marked off is called
the boundary, with the rectangle “pitch” in the centre.
At each end of the pitch are the wickets, 22 yards apart. A bowling crease is in
line with the wicket and the batting or popping crease is 4ft in front of the wicket.
7
Jargon buster
Batsman – individual who is batting. Attempting to bat away the ball with
being made out.
Run – when a batsman completes a run from one crease to another, without
fielders knocking off stumps.
Crease – a bowler cannot deliver the ball beyond the bowling crease. A
batman’s must be inside the batting crease before a fielder knocks off his
stumps.
Wicket keeper (one of the fielding team) is positioned directly behind the
wicket.
LBW leg before wicket – when the batsman prevents the ball hitting the wicket
with his leg. Umpire – 2 umpires regulate the match referee. One behind the
wicket at the bowling end and the other at square leg.
Run out – when the batsman is outside the wicket he owns, outside his crease
when fielding team remove stump/s
8
Who is cricket for?
Men, woman, children and seniors can play cricket. If you are looking for a place
to start your child playing cricket, then Check fit will provide you with some
information as a first point of contact.
A lot of senior schools have after-school cricket clubs and there are many other
ways to get you playing the game.
If you are interested in playing women's or girls' cricket, then Check Fit will be
able to provide information on potential clubs in your area.
9
Source code
# Cricket Game
Instructions:
3. While batting, if the number selected by you and computer is different, then
your number will add to your runs.
If the number selected by you and computer is same, then you will lose your
wicket.
4. While bowling, if the number selected by you and computer is different, then
the computer's number will add to its runs.
If the number selected by you and computer is same, then the computer will
lose its wicket.
5. Each player will get 2 wickets and 2 overs (12 balls) for batting and
bowling.
6. The innings will end after either the three wickets fell or the overs end.
10
import random
# Toss
u_opt = 0
c_opt = 0
11
else:
if random_opt == 1:
c_opt = "bat"
elif random_opt == 2:
c_opt = "ball"
# First Innings
runs_1 = 0
wickets_1 = 0
balls_1 = 0
12
c_choice = random.randint(1,6)
else:
if u_choice == c_choice:
wickets_1 += 1
else:
Bat_first = "You"
Ball_first = "Computer"
runs_1 += u_choice
Bat_first = "Computer"
Ball_first = "You"
runs_1 += c_choice
print("\nScore =",runs_1,"/",wickets_1)
13
balls_1 += 1
if balls_1 == 6:
print("\nFinal Score:")
print("Runs =",runs_1)
print("wickets =",wickets_1)
# Second Innings
14
runs_2 = 0
wickets_2 = 0
balls_2 = 0
c_choice = random.randint(1,6)
else:
if u_choice == c_choice:
wickets_2 += 1
else:
if Bat_first == "Computer":
runs_2 += u_choice
Bat_second = "You"
15
elif Bat_first == "You": runs_2
+= c_choice Bat_second =
"Computer"
print("\nScore =",runs_2,"/",wickets_2)
balls_2 += 1
if balls_2 == 6:
print("\nFinal Score:")
print("Runs =",runs_2)
print("wickets =",wickets_2)
16
# Result of Match
if Bat_first == "You":
else:
if Bat_second == "You":
else:
print("\nBetter luck next time! The Computer won the Match by",2 -
wickets_2,"wickets.")
17
else:
18
Output
19
20
21
22
23
24
HARDWARE AND SOFTWARE REQUIREMENTS
DUALCORE)
K9MM-V VIAK8M800+8237R
ATHALON
SOFTWARE REQUIREMENTS:
I. Windows OS
II. Python
25
BIBLIOGRAPHY
26
THANK
YOU!!!
27