0% found this document useful (0 votes)
30 views21 pages

Project Doc

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views21 pages

Project Doc

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

TABLE OF CONTENTS

S.NO DESCRIPTION PAGE


01) INTRODUCTION 02-03

02) OBJECTIVES OF THE PROJECT 04-05


03) PROPOSED SYSTEM 06-07
04) ABSTRACT 08-09
05) HARDWARE AND SOFTWARE 10-11
REQUIREMENTS
06) SOURCE CODE 12-15
07) SCREENSHOTS 16-17
08) CONCLUSION 18-19
09) BIBLIOGRAPHY 20-21

01
INTRODUCTION

02
This project introduces PyCricket, a well-designed
Python program that brings the classic game of
hand cricket into the digital world.
PyCricket offers an easy-to-use platform where
players can dive into a simplified but engaging
version of the traditional game.
By using numbers to represent the gameplay, the
program creates an interactive experience that is
both straightforward and fun.

The game is designed to be user-friendly,


allowing players to participate in competitive
matches by making numerical guesses that
influence their ability to score runs.
It captures the essence of hand cricket, providing
the thrill and strategic depth of the game without
needing physical equipment.
This digital version is accessible to players of all
experience levels, offering a simple yet
captivating way to enjoy hand cricket in a new,
online format.

03
OBJECTIVES OF THE
PROJECT

04
The main goal of this project is to create a Python
program that brings the essence of hand cricket
to life.

Players will take turns using numerical guesses to


score runs and compete against a computer
opponent. Beyond just simulating the basic
gameplay, the project will also include features
like customizable rules, different difficulty settings
for the computer, and detailed score tracking.

These additions are designed to make the game


more engaging and enjoyable, providing a fresh,
interactive version of hand cricket that retains the
excitement of the original game while offering
new challenges.

05
PROPOSED SYSTEM

06
PyCricket employs a turn-based structure.

Players take turns guessing numbers within a


designated range.

Correct guesses accumulate points as runs,


while identical guesses between player and
computer result in an "out."

The program culminates by declaring the winner


based on the highest accumulated score after a
predetermined number of rounds (overs).

07
ABSTRACT

08
This project creates a Python program that brings
the classic game of hand cricket into a digital
space. Players take turns making numerical
guesses to score runs and try to outsmart a
computer opponent, which adds an element of
strategy and unpredictability.

The program features a dynamic scorekeeping


system that tracks each player’s performance
throughout the match. Ultimately, the winner is
determined by the total points accumulated by
each player, making for an engaging and
competitive experience that mirrors the
excitement of the real game.

09
HARDWARE &
SOFTWARE
REQUIREMENTS

10
Hardware: A standard personal computer (PC) or
laptop with sufficient memory (RAM) is required.
Minimal storage space is necessary for the
Python interpreter and program itself.

Software: A text editor compatible with Python


(e.g., IDLE, VScode, Jupiter Notebook) and Python
version 3.12.3 (or above).

11
SOURCE CODE

12
1 import random

2 def input_num(min_val, max_val):

3 while True:

4 try:

5 num = int(input())

6 if min_val <= num <= max_val:

7 return num

8 else:

9 print("Enter a valid choice between", min_val, "and", max_val)

10 except ValueError:

11 print("Enter a valid integer choice")

12 def innings(batsman, to_chase):

13 print("\nEnter numbers between 1 and 6. If you both choose the same


number then " + batsman + " is out")

14 total = 0

15 while True:

16 pnum = input_num(1, 6)

17 cnum = random.randint(1, 6)

18 print("\nUser chose:", pnum)

19 print("Opponent Player chose:", cnum)

20 if pnum == cnum:

21 print(batsman + " is out!")

22 return total

23 else:

24 total += (pnum if batsman == "User" else cnum)

13
25 print(batsman + " score is", total)

26 if to_chase is not None and total > to_chase:

27 return total

28 print("Welcome to the Cricket Match Simulation!")

29 print("\nTime for the toss. Enter 0 for Heads and 1 for Tails:")

30 choice = input_num(0, 1)

31 coin = random.randint(0, 1)

32 player_bowls = False

33 if coin == choice:

34 print("\nYou won the toss!")

35 print("Select 0 to bat, 1 to bowl:")

36 player_bowls = input_num(0, 1) == 1

37 if player_bowls:

38 print("You chose to bowl.")

39 else:

40 print("You chose to bat.")

41 else:

42 print("\nOpponent Player won the toss!")

43 player_bowls = random.randint(0, 1) == 1

44 if player_bowls:

45 print("Opponent Player chose to bat.")

46 else:

47 print("Opponent Player chose to bowl.")

48 if player_bowls:

49 opponent_score = innings("Opponent Player", None)

14
50 print("\nYou need to score at least", opponent_score + 1, "runs to win.")

51 user_score = innings("User", opponent_score)

52 else:

53 user_score = innings("User", None)

54 print("\nOpponent Player needs to score at least", user_score + 1, "runs to


win.")

55 opponent_score = innings("Opponent Player", user_score)

56 print("\nMatch Results:")

57 print("User Score:", user_score)

58 print("Opponent Player Score:", opponent_score)

59 if opponent_score < user_score:

60 print("User wins!")

61 elif user_score < opponent_score:

62 print("Opponent Player wins!")

63 else:

64 print("Match drawn!")

15
SCREENSHOTS

16
17
CONCLUSION

18
This project is a hands-on example of various
Python concepts and techniques we've learned
throughout the course. Developing PyCricket
involves applying key programming principles like
user-defined functions to keep the code
organized and readable.

Conditional statements help decide the


outcomes of the game based on what the players
do, while loops are used to handle repetitive tasks
and keep the game running smoothly.

The project also makes use of the random module


to add unpredictability and excitement,
mimicking the real game's variability.

By bringing these elements together in an


interactive game, PyCricket not only shows how
Python skills can be applied in a practical way but
also creates an engaging and fun experience for
players.

19
BIBLIOGRAPHY

20
• Computer Science with Python (XII) – Sumita
Arora (TEXT BOOK)

• Reference website:
https://www.geeksforgeeks.org

21

You might also like