CS PROJECT - Merged
CS PROJECT - Merged
S. Sarvesh
CHENNAI
TABLE OF CONTENTS
2 Abstract 4
3 Requirements 5
4 Built-in Functions 6
5 Data structures 7
6 Libraries 8
8 Output 16-17
9 Future Outlook 18
10 Bibliography 19
Overview of Python
History of python
Python was developed by Guido van Rossum in the year 1991 at
National Research Institute for Mathematics and Computer
Science in the Netherlands. Guido van Rossum born 31 January
1956 is a Dutch programmer. In his childhood he was very much
interested in electronics and
He was getting top grades in his high school, and he was learning
more about electronic out of curiosity he even posted an article
about electric circuit. Then at the college days his total perspective
way of seeing thing has undergone a change, so his peaking
interest moves towards programming. This all began when he was
developing a digital calculator this is the starting point where he
began to understand the greatness of software ,so this let his
curiosity to grow extraordinary and in his experiences makes him
to many idea that pop into his head in one such idea was creating
an open source software which we can understand well and easy
then he used after several years he create a software that is python
this software was purposefully created for himself .after then he
introduced to some people which people find its useful and easy
to use by seeing everybody using python Guido decided to release
python to the world then python became famous
Python features
Easy-to-learn − Python has few keywords, simple structure, and a
clearly
Defined syntax. This allows the student to pick up the language
quickly.
Page 1 of 19
Easy-to-read − Python code is more clearly defined and visible to
the eyes.
Page 2 of 19
systems, such as Windows MFC, Macintosh, and the X Window
system of Unix.
DERIVED FROM:
Python is derived from many other languages, including ABC,
Modula-3, C, C++, Algol-68, Smalltalk, and UNIX shell and other
scripting languages.
Page 3 of 19
ABSTRACT
In this project we are going to make the python interpreter play
with the user operating it. This is the traditional game of cricket
where most of the rules are followed. You can see your runs,
wicket, overs etc.
Page 4 of 19
Requirements
Hardware:
Windows 7 or 10
Intel Core i5 processor or equivalent
5 GB available hard disk space
Mac OS X 10.11 or higher, 64-bit
Linux: RHEL 6/7, 64-bit (almost all libraries also work in Ubuntu)
x86 64-bit CPU (Intel / AMD architecture)
4GB Ram
Software:
Windows 7 or 10
Download the latest version of python.
Libraries needed random.
The Python download requires about 18 MB of disk space
Page 5 of 19
Built-in Functions
Range:
Print:
Page 6 of 19
Data structures
Page 7 of 19
Libraries
Random:
Random module is an in-built module of Python which is
used to generate random numbers.
Page 8 of 19
SOURCE CODE
import random
# overs
a = input(
"do u want overs or unlimited overs. 'no' for unlimted and 'yes'
for over match :")
if a == 'no':
overs = -1
else:
overs = int(input("no . of .overs :"))
# wickets
wics = input(
"type 'no' for unlimted wickets or no of wickets to have wickets:")
if wics == "no":
wics = -1
wics = int(wics)
tn = input("enter ur team name :")
print("Lets start the game", end=' ')
tos = input("H for head and T for tails :")
rcoin = random.choice(['H', 'T'])
if tos == rcoin:
print("u have won the toss")
bob = input("'B' to bat and 'F' to field :")
else:
print("AI has won the toss")
Page 9 of 19
bobai = random.choice(["Bat", "Field"])
print("AI has chose to ", bobai)
if bobai == "Bat":
bob = "F"
elif bobai == "Field":
bob = "B"
if bob == "B":
y=0
pscore = 0
ball = 1
over = 0
wic = 0
while(wic != wics and over != overs):
print("over-{} :balls-{} : score-{} - wics -{} ".format(over, ball,
pscore, wic))
hit = int(input("what run do u wanna hit the ball with :"))
aiball = random.randrange(0, 11)
while hit < 0 or hit > 10:
hit = int(input("type a range within 0 to 10"))
print(aiball)
ball += 1
if ball == 7:
over += 1
ball = 1
if aiball == hit:
wic += 1
else:
pscore += hit
Page 10 of 19
if bob == 'F':
if pscore > y:
break
if wic == wics:
print("Ai has taken all ur wickets")
if over == overs:
print("u have played the max no of balls")
print("score-{} - wics -{} ".format(pscore, wic))
''' if bob == 'F':
if pscore > y[0]:
print("U have won AI by {}".format(pscore-y))
else:
print("AI has won u by {}".format(y-pscore))'''
n =pscore
print("target for Ai is ", n+1)
aiscore = 0
ball = 1
over = 0
wic = 0
while(wic != wics and over != overs):
print("over-{} :balls-{} : aiscore-{} - wics taken -{} ".format(over,
ball, aiscore, wic))
bowl = int(input("what run do u guess the AI might hit the
ball with :"))
aibat = random.randrange(0, 11)
while bowl < 0 or bowl > 10:
bowl = int(input("type a range within 0 to 10"))
print(aibat)
Page 11 of 19
ball += 1
if ball == 7:
over += 1
ball = 1
if aibat == bowl:
wic += 1
else:
aiscore += aibat
if bob == 'B':
if aiscore > n:
break
if wic == wics:
print("U have taken all AI wickets")
if over == overs:
print("over up")
print("aiscore-{} - wics taken -{} ".format(aiscore, wic))
''' if bob == 'B':
if aiscore > n[0]:
print("AI has won u by {}".format(aiscore-n[0]))
else:
print("U have won AI by {}".format(n[0]-aiscore))'''
y =aiscore
Page 12 of 19
wic = 0
while(wic != wics and over != overs):
print("over-{} :balls-{} : aiscore-{} - wics taken -{} ".format(over,
ball, aiscore, wic))
bowl = int(input("what run do u guess the AI might hit the
ball with :"))
aibat = random.randrange(0, 11)
while bowl < 0 or bowl > 10:
bowl = int(input("type a range within 0 to 10"))
print(aibat)
ball += 1
if ball == 7:
over += 1
ball = 1
if aibat == bowl:
wic += 1
else:
aiscore += aibat
if bob == 'B':
if aiscore > n:
break
if wic == wics:
print("U have taken all AI wickets")
if over == overs:
print("over up")
print("aiscore-{} - wics taken -{} ".format(aiscore, wic))
''' if bob == 'B':
if aiscore > n[0]:
Page 13 of 19
print("AI has won u by {}".format(aiscore-n[0]))
else:
print("U have won AI by {}".format(n[0]-aiscore))'''
y =aiscore
print("target is ", y+1)
pscore = 0
ball = 1
over = 0
wic = 0
while(wic != wics and over != overs):
print("over-{} :balls-{} : score-{} - wics -{} ".format(over, ball,
pscore, wic))
hit = int(input("what run do u wanna hit the ball with :"))
aiball = random.randrange(0, 11)
while hit < 0 or hit > 10:
hit = int(input("type a range within 0 to 10"))
print(aiball)
ball += 1
if ball == 7:
over += 1
ball = 1
if aiball == hit:
wic += 1
else:
pscore += hit
if bob == 'F':
if pscore > y:
break
Page 14 of 19
if wic == wics:
print("Ai has taken all ur wickets")
if over == overs:
print("u have played the max no of balls")
print("score-{} - wics -{} ".format(pscore, wic))
''' if bob == 'F':
if pscore > y[0]:
print("U have won AI by {}".format(pscore-y))
else:
print("AI has won u by {}".format(y-pscore))'''
n=pscore
if n>y:
print('u have won')
elif n==y:
print('it is an draw')
else:
print('ai has won')
Page 15 of 19
OUTPUT
Page 16 of 19
Page 17 of 19
FUTURE OUTLOOK
In future this project can be made into a mobile game.
Using some other features available we can make it much more
interesting and colourfully presented in an output screen.
Page 18 of 19
BIBLIOGRAPHY
SL AURORA
NCERT Computer Science Textbook
Page 19 of 19