SlideShare a Scribd company logo
1 of 20
Name: Rudra pratap singh
Roll NO : Class : Xll
SCI
SCHOOL : A.P.S ACADEMY
This is to cerify that the bonafide work of F.I.T (Practical / Project) has
been done by the student as per CBSE requirement during the
academic session : 2019-2020
Examiner’s signature Teacher – In – charge
Date HEAD OF INSTITUTION
I WOULD LIKE TO EXPRESS MY SPECIAL
THANKS OF GRATITUDE TO MY TEACHER
MRS. DEEPIKA MULLICK AS WELL AS OUR
PRINCIPAL MRS. HEMA KALAKOTI WHO
GAVE ME THE GOLDEN OPPORTUNITY TO
DO THIS WONDERFUL PROJECT ON THE
TOPIC GAMEING PROGRAM WHICH ALSO
HELPED ME IN DOING A LOT OF RESEARCH
AND I COME TO KNOW ABOUT SO MANY
NEW THINGS I AM REALLY THANKFUL TO
THEM.
SECONDLY I WOULD ALSO LIKE TO THANK
MY PARENTS AND FRIENDS WHO HELPED
ME A LOT IN FINALIZING THIS PROJECT
WITHIN THE LIMITED TIME FRAME.
importrandom
importcollections
random.seed(1)
size = 5
bombs = collections.defaultdict(int)
counts = collections.defaultdict(int)
display = collections.defaultdict(lambda: 'X')
neighbors = sorted(set((i, j) for i in range(size) for j in range(size)) - {(0, 0)})
# Initialize
for x in range(size):
for y in range(size):
bombs[x, y] = 0
counts[x, y] = 0
display[x, y] = '?'
# Set bombs
for _ in range(3):
x = random.randrange(size)
y = random.randrange(size)
bombs[x, y] = 1
# Calculate counts
for x in range(size):
for y in range(size):
total = 0
for i in [-1, 0, 1]:
for j in [-1, 0, 1]:
total += bombs[x + i, y + j]
counts[x, y] = total
def show(grid):
for x in range(size):
for y in range(size):
print(grid[x, y], end=', ')
print()
print('Bombs:')
show(bombs)
print('Counts:')
show(counts)
alive = True
def reveal(x, y):
if bombs[x, y]:
return False
display[x, y] = counts[x, y]
if counts[x, y]:
return True
zeros = [ (x, y) ]
while zeros:
x, y = zeros.pop()
if not ((0 <= x < size) and (0 <= y < size)):
continue
if counts[x, y] == 0:
display[x, y] = 0
for i in (-1, 0, 1):
for j in (-1, 0, 1):
if i == j == 0:
continue
offset_x = x + i
offset_y = y + j
seen = display[offset_x, offset_y] != '?'
if counts[offset_x, offset_y] == 0 and notseen:
zeros.append((offset_x, offset_y))
return True
while alive:
show(display)
x = int(input('row: '))
y = int(input('column: '))
alive = reveal(x, y)
if not alive or not any(spot== '?' for spotin display.values()):
break
if alive:
print('Congratulations!You win.')
else:
print('Sorry, you failed.')
----------------------------------------------------------------------------------------------------
-------------------------
importatexit
importcollections
importitertools
importrandom
importsqlite3
importthreading
importtime
importconsole
original_terminal_state = console.get_terminal_mode()
atexit.register(console.set_terminal_mode, original_terminal_state)
class Game:
"Game state for Tetris."
def __init__(self, width, height, seed=None):
self.random = random.Random(seed)
self.width= width
self.height = height
self.board = collections.defaultdict(lambda: '#')
for x in range(width):
for y in range(height):
self.board[x, y] = ' '
self.active = True
self.speed = 20
self.next_letter = self.random.choice('IJLOSTZ')
self.piece = self.next_piece()
self.score = 0
self.stash = None
def draw(self):
"Draw game state."
print('Score:', self.score, end='rn')
print('Level:', self.score// 4 + 1, end='rn')
print('Nextpiece:', self.next_letter, end='rn')
print('Stash piece:', 'no' if self.stash is Noneelse 'yes', end='rn')
print('*' * (self.width + 2), end='rn')
for y in range(self.height):
print('|', end='')
for x in range(self.width):
if (x, y) in self.piece:
print('@', end='')
else:
print(self.board[x, y], end='')
print('|', end='rn')
print('*' * (self.width + 2), end='rn')
def next_piece(self):
"Create a new piece, on collision set active to False."
letter = self.next_letter
self.next_letter = self.random.choice('IJLOSTZ')
if letter == 'I':
piece = {(0, 0), (0, 1), (0, 2), (0, 3)}
elif letter == 'J':
piece = {(1, 0), (1, 1), (1, 2), (0, 2)}
elif letter == 'L':
piece = {(0, 0), (0, 1), (0, 2), (1, 2)}
elif letter == 'O':
piece = {(0, 0), (0, 1), (1, 0), (1, 1)}
elif letter == 'S':
piece = {(0, 1), (1, 0), (1, 1), (2, 0)}
elif letter == 'T':
piece = {(0, 0), (1, 0), (2, 0), (1, 1)}
else:
assert letter == 'Z'
piece = {(0, 0), (1, 0), (1, 1), (2, 1)}
offset = self.width // 2 - 1
piece = {(x + offset, y) for x, y in piece}
if self.collide(piece):
self.end()
return piece
def end(self):
self.active = False
print('Gameover!Pressany key to quit.', end='rn')
def tick(self, mark):
"Notify the game of a clock tick."
if mark % self.speed == 0:
moved = self.move_piece(0, 1)
if not moved:
for x, y in self.piece:
self.board[x, y] = '#'
self.collapse()
self.piece = self.next_piece()
self.draw()
def collapse(self):
"Collapse fulllines."
y = self.height - 1
while y >= 0:
full_line= all(self.board[x, y] == '#' for x in range(self.width))
if full_line:
z = y
while z > 0:
for x in range(self.width):
self.board[x, z] = self.board[x, z - 1]
z -= 1
for x in range(self.width):
self.board[x, 0] = ' '
self.score += 1
if self.score % 4 == 0:
self.speed -= 1
else:
y -= 1
def collide(self, piece):
"Check whether piece collides with others on board."
return any(self.board[x, y] != ' ' for x, y in piece)
def move_piece(self, x, y):
"Movepiece by delta x and y."
new_piece= {(a + x, y + b) for a, b in self.piece}
if self.collide(new_piece):
return False
self.piece = new_piece
return True
def rotate_piece(self):
"Rotate piece."
min_x = min(xfor x, y in self.piece)
max_x = max(x for x, y in self.piece)
diff_x = max_x - min_x
min_y = min(y for x, y in self.piece)
max_y = max(y for x, y in self.piece)
diff_y = max_y - min_y
size = max(diff_x, diff_y)
new_piece= set()
for x, y in self.piece:
pair = (min_x + size) - (y - min_y), min_y + (x - min_x)
new_piece.add(pair)
if self.collide(new_piece):
return False
self.piece = new_piece
return True
def move(self, key):
"Update game state based on key press."
if key == 'left':
moved = self.move_piece(-1, 0)
elif key == 'right':
moved = self.move_piece(1, 0)
elif key == 'down':
moved = self.move_piece(0, 1)
elif key == 'up':
moved = self.rotate_piece()
elif key == 'swap':
if self.stash is None:
self.stash = self.piece
self.piece = self.next_piece()
else:
self.piece, self.stash = self.stash, self.piece
if self.collide(self.piece):
self.end()
moved = True
else:
assert key == 'space'
moved = self.move_piece(0, 1)
while moved:
moved = self.move_piece(0, 1)
moved = True
if moved:
self.draw()
def draw_loop(game):
game.draw()
counter = itertools.count(start=1)
while game.active:
mark = next(counter)
game.tick(mark)
time.sleep(0.1)
def input_loop(game):
"""Input loop.
Handlekeyboard inputin a separate thread.
"""
while game.active:
key = console.get_input()
if key is None:
continue
elif key == 'quit':
game.active = False
else:
assert key in ('left', 'down', 'right', 'up', 'space', 'swap')
game.move(key)
console.set_terminal_mode(original_terminal_state)
print('Enter your namefor leaderboard (blank to ignore):')
name = input()
if name:
con = sqlite3.connect('tetris.sqlite3', isolation_level=None)
con.execute('CREATE TABLE IFNOT EXISTS Leaderboard (name, score)')
con.execute('INSERTINTO Leaderboard VALUES (?, ?)', (name,
game.score))
scores = con.execute('SELECT* FROM Leaderboard ORDER BY score
DESC LIMIT 10')
print('{0:<16}| {1:<16}'.format('Name', 'Score'))
for pair in scores:
print('{0:<16}| {1:<16}'.format(*pair))
def main():
"Main entry-pointfor Tetris."
game = Game(10, 10)
draw_thread = threading.Thread(target=draw_loop, args=(game,))
input_thread = threading.Thread(target=input_loop, args=(game,))
draw_thread.start()
input_thread.start()
draw_thread.join()
input_thread.join()
if __name__ == '__main__':
main()
---------------------------------------------------------------------------------------------------
import time
from time import sleep
import random
sus="-"*35
depo=["rock","paper","scissors"]
while True:
x=input("rock , paper, scissors: ")
if x not in depo:
print ("Dontcheat!")
continue
pc=random.choice(depo)
sleep(0.5)
print (("Computer picked {}.").format(pc))
if x==pc:
sleep(0.5)
print (("nIt's a draw.n{}").format(sus))
elif x=="rock" and pc=="scissors":
sleep(0.5)
print (("nYou win.rock beats scissorsn{}").format(sus))
elif x=="paper" and pc=="rock":
sleep(0.5)
print (("nYou win.paper beats rockn{}").format(sus))
elif x=="scissors" and pc=="paper":
sleep(0.5)
print (("nYou win.scissors beats papern{}").format(sus))
else:
sleep(0.5)
print (("nYou lose. {} beats {}n{}").format(pc,x,sus))
input()
New microsoft office word document

More Related Content

What's hot

The Ring programming language version 1.8 book - Part 57 of 202
The Ring programming language version 1.8 book - Part 57 of 202The Ring programming language version 1.8 book - Part 57 of 202
The Ring programming language version 1.8 book - Part 57 of 202Mahmoud Samir Fayed
 
Intro to Game Programming
Intro to Game ProgrammingIntro to Game Programming
Intro to Game ProgrammingRichard Jones
 
The Ring programming language version 1.7 book - Part 55 of 196
The Ring programming language version 1.7 book - Part 55 of 196The Ring programming language version 1.7 book - Part 55 of 196
The Ring programming language version 1.7 book - Part 55 of 196Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 50 of 181
The Ring programming language version 1.5.2 book - Part 50 of 181The Ring programming language version 1.5.2 book - Part 50 of 181
The Ring programming language version 1.5.2 book - Part 50 of 181Mahmoud Samir Fayed
 
Utility Classes Are Killing Us
Utility Classes Are Killing UsUtility Classes Are Killing Us
Utility Classes Are Killing UsYegor Bugayenko
 
The Ring programming language version 1.6 book - Part 53 of 189
The Ring programming language version 1.6 book - Part 53 of 189The Ring programming language version 1.6 book - Part 53 of 189
The Ring programming language version 1.6 book - Part 53 of 189Mahmoud Samir Fayed
 
The Ring programming language version 1.5 book - Part 9 of 31
The Ring programming language version 1.5 book - Part 9 of 31The Ring programming language version 1.5 book - Part 9 of 31
The Ring programming language version 1.5 book - Part 9 of 31Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 46 of 185
The Ring programming language version 1.5.4 book - Part 46 of 185The Ring programming language version 1.5.4 book - Part 46 of 185
The Ring programming language version 1.5.4 book - Part 46 of 185Mahmoud Samir Fayed
 
The Ring programming language version 1.4.1 book - Part 15 of 31
The Ring programming language version 1.4.1 book - Part 15 of 31The Ring programming language version 1.4.1 book - Part 15 of 31
The Ring programming language version 1.4.1 book - Part 15 of 31Mahmoud Samir Fayed
 
Silverlight as a Gaming Platform
Silverlight as a Gaming PlatformSilverlight as a Gaming Platform
Silverlight as a Gaming Platformgoodfriday
 
The Ring programming language version 1.9 book - Part 62 of 210
The Ring programming language version 1.9 book - Part 62 of 210The Ring programming language version 1.9 book - Part 62 of 210
The Ring programming language version 1.9 book - Part 62 of 210Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 56 of 202
The Ring programming language version 1.8 book - Part 56 of 202The Ring programming language version 1.8 book - Part 56 of 202
The Ring programming language version 1.8 book - Part 56 of 202Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 55 of 202
The Ring programming language version 1.8 book - Part 55 of 202The Ring programming language version 1.8 book - Part 55 of 202
The Ring programming language version 1.8 book - Part 55 of 202Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 51 of 185
The Ring programming language version 1.5.4 book - Part 51 of 185The Ring programming language version 1.5.4 book - Part 51 of 185
The Ring programming language version 1.5.4 book - Part 51 of 185Mahmoud Samir Fayed
 
Ch11 Search & Sort
Ch11 Search & SortCh11 Search & Sort
Ch11 Search & Sortleminhvuong
 
PyCon2009_AI_Alt
PyCon2009_AI_AltPyCon2009_AI_Alt
PyCon2009_AI_AltHiroshi Ono
 

What's hot (17)

The Ring programming language version 1.8 book - Part 57 of 202
The Ring programming language version 1.8 book - Part 57 of 202The Ring programming language version 1.8 book - Part 57 of 202
The Ring programming language version 1.8 book - Part 57 of 202
 
Intro to Game Programming
Intro to Game ProgrammingIntro to Game Programming
Intro to Game Programming
 
The Ring programming language version 1.7 book - Part 55 of 196
The Ring programming language version 1.7 book - Part 55 of 196The Ring programming language version 1.7 book - Part 55 of 196
The Ring programming language version 1.7 book - Part 55 of 196
 
pptuni1
pptuni1pptuni1
pptuni1
 
The Ring programming language version 1.5.2 book - Part 50 of 181
The Ring programming language version 1.5.2 book - Part 50 of 181The Ring programming language version 1.5.2 book - Part 50 of 181
The Ring programming language version 1.5.2 book - Part 50 of 181
 
Utility Classes Are Killing Us
Utility Classes Are Killing UsUtility Classes Are Killing Us
Utility Classes Are Killing Us
 
The Ring programming language version 1.6 book - Part 53 of 189
The Ring programming language version 1.6 book - Part 53 of 189The Ring programming language version 1.6 book - Part 53 of 189
The Ring programming language version 1.6 book - Part 53 of 189
 
The Ring programming language version 1.5 book - Part 9 of 31
The Ring programming language version 1.5 book - Part 9 of 31The Ring programming language version 1.5 book - Part 9 of 31
The Ring programming language version 1.5 book - Part 9 of 31
 
The Ring programming language version 1.5.4 book - Part 46 of 185
The Ring programming language version 1.5.4 book - Part 46 of 185The Ring programming language version 1.5.4 book - Part 46 of 185
The Ring programming language version 1.5.4 book - Part 46 of 185
 
The Ring programming language version 1.4.1 book - Part 15 of 31
The Ring programming language version 1.4.1 book - Part 15 of 31The Ring programming language version 1.4.1 book - Part 15 of 31
The Ring programming language version 1.4.1 book - Part 15 of 31
 
Silverlight as a Gaming Platform
Silverlight as a Gaming PlatformSilverlight as a Gaming Platform
Silverlight as a Gaming Platform
 
The Ring programming language version 1.9 book - Part 62 of 210
The Ring programming language version 1.9 book - Part 62 of 210The Ring programming language version 1.9 book - Part 62 of 210
The Ring programming language version 1.9 book - Part 62 of 210
 
The Ring programming language version 1.8 book - Part 56 of 202
The Ring programming language version 1.8 book - Part 56 of 202The Ring programming language version 1.8 book - Part 56 of 202
The Ring programming language version 1.8 book - Part 56 of 202
 
The Ring programming language version 1.8 book - Part 55 of 202
The Ring programming language version 1.8 book - Part 55 of 202The Ring programming language version 1.8 book - Part 55 of 202
The Ring programming language version 1.8 book - Part 55 of 202
 
The Ring programming language version 1.5.4 book - Part 51 of 185
The Ring programming language version 1.5.4 book - Part 51 of 185The Ring programming language version 1.5.4 book - Part 51 of 185
The Ring programming language version 1.5.4 book - Part 51 of 185
 
Ch11 Search & Sort
Ch11 Search & SortCh11 Search & Sort
Ch11 Search & Sort
 
PyCon2009_AI_Alt
PyCon2009_AI_AltPyCon2009_AI_Alt
PyCon2009_AI_Alt
 

Similar to New microsoft office word document

Retos de Programación en Python
Retos de Programación en PythonRetos de Programación en Python
Retos de Programación en PythonJavier Abadía
 
19012011102_Nayan Oza_Practical-7_AI.pdf
19012011102_Nayan Oza_Practical-7_AI.pdf19012011102_Nayan Oza_Practical-7_AI.pdf
19012011102_Nayan Oza_Practical-7_AI.pdfNayanOza
 
Please help me fix this code! will upvote. The code needs to produce .pdf
Please help me fix this code! will upvote.  The code needs to produce .pdfPlease help me fix this code! will upvote.  The code needs to produce .pdf
Please help me fix this code! will upvote. The code needs to produce .pdfclimatecontrolsv
 
Please help this code is supposed to evaluate current node state and i.pdf
Please help this code is supposed to evaluate current node state and i.pdfPlease help this code is supposed to evaluate current node state and i.pdf
Please help this code is supposed to evaluate current node state and i.pdfclimatecontrolsv
 
AI_Lab_File()[1]sachin_final (1).pdf
AI_Lab_File()[1]sachin_final (1).pdfAI_Lab_File()[1]sachin_final (1).pdf
AI_Lab_File()[1]sachin_final (1).pdfpankajkaushik2216
 
calculator_new (1).pdf
calculator_new (1).pdfcalculator_new (1).pdf
calculator_new (1).pdfni30ji
 
This is a homework assignment that I have for my Java coding class. .pdf
This is a homework assignment that I have for my Java coding class. .pdfThis is a homework assignment that I have for my Java coding class. .pdf
This is a homework assignment that I have for my Java coding class. .pdffeelinggift
 
Mylib.pydef allInOne(n1, n2) return {addplus(n1, n2).docx
Mylib.pydef allInOne(n1, n2)    return {addplus(n1, n2).docxMylib.pydef allInOne(n1, n2)    return {addplus(n1, n2).docx
Mylib.pydef allInOne(n1, n2) return {addplus(n1, n2).docxroushhsiu
 
Mylib.pydef allInOne(n1, n2) return {addplus(n1, n2.docx
Mylib.pydef allInOne(n1, n2)    return {addplus(n1, n2.docxMylib.pydef allInOne(n1, n2)    return {addplus(n1, n2.docx
Mylib.pydef allInOne(n1, n2) return {addplus(n1, n2.docxgemaherd
 
Py Die R E A D M E
Py Die  R E A D M EPy Die  R E A D M E
Py Die R E A D M Ecfministries
 
λ | Lenses
λ | Lensesλ | Lenses
λ | LensesOpen-IT
 
Will upvote asapPlease help my code gives me incorrect val.pdf
Will upvote asapPlease help my code gives me incorrect val.pdfWill upvote asapPlease help my code gives me incorrect val.pdf
Will upvote asapPlease help my code gives me incorrect val.pdfsales223546
 
Will upvote Please fix the following code and post your inputs and o.pdf
Will upvote Please fix the following code and post your inputs and o.pdfWill upvote Please fix the following code and post your inputs and o.pdf
Will upvote Please fix the following code and post your inputs and o.pdfinfo335653
 
関数プログラミングことはじめ revival
関数プログラミングことはじめ revival関数プログラミングことはじめ revival
関数プログラミングことはじめ revivalNaoki Kitora
 
Fix this code so that it will run with proper answers, please dont u.pdf
Fix this code so that it will run with proper answers, please dont u.pdfFix this code so that it will run with proper answers, please dont u.pdf
Fix this code so that it will run with proper answers, please dont u.pdftxkev
 

Similar to New microsoft office word document (20)

Retos de Programación en Python
Retos de Programación en PythonRetos de Programación en Python
Retos de Programación en Python
 
19012011102_Nayan Oza_Practical-7_AI.pdf
19012011102_Nayan Oza_Practical-7_AI.pdf19012011102_Nayan Oza_Practical-7_AI.pdf
19012011102_Nayan Oza_Practical-7_AI.pdf
 
p.pdf
p.pdfp.pdf
p.pdf
 
Please help me fix this code! will upvote. The code needs to produce .pdf
Please help me fix this code! will upvote.  The code needs to produce .pdfPlease help me fix this code! will upvote.  The code needs to produce .pdf
Please help me fix this code! will upvote. The code needs to produce .pdf
 
Please help this code is supposed to evaluate current node state and i.pdf
Please help this code is supposed to evaluate current node state and i.pdfPlease help this code is supposed to evaluate current node state and i.pdf
Please help this code is supposed to evaluate current node state and i.pdf
 
AI_Lab_File()[1]sachin_final (1).pdf
AI_Lab_File()[1]sachin_final (1).pdfAI_Lab_File()[1]sachin_final (1).pdf
AI_Lab_File()[1]sachin_final (1).pdf
 
calculator_new (1).pdf
calculator_new (1).pdfcalculator_new (1).pdf
calculator_new (1).pdf
 
This is a homework assignment that I have for my Java coding class. .pdf
This is a homework assignment that I have for my Java coding class. .pdfThis is a homework assignment that I have for my Java coding class. .pdf
This is a homework assignment that I have for my Java coding class. .pdf
 
Mylib.pydef allInOne(n1, n2) return {addplus(n1, n2).docx
Mylib.pydef allInOne(n1, n2)    return {addplus(n1, n2).docxMylib.pydef allInOne(n1, n2)    return {addplus(n1, n2).docx
Mylib.pydef allInOne(n1, n2) return {addplus(n1, n2).docx
 
Mylib.pydef allInOne(n1, n2) return {addplus(n1, n2.docx
Mylib.pydef allInOne(n1, n2)    return {addplus(n1, n2.docxMylib.pydef allInOne(n1, n2)    return {addplus(n1, n2.docx
Mylib.pydef allInOne(n1, n2) return {addplus(n1, n2.docx
 
Py Die R E A D M E
Py Die  R E A D M EPy Die  R E A D M E
Py Die R E A D M E
 
λ | Lenses
λ | Lensesλ | Lenses
λ | Lenses
 
Will upvote asapPlease help my code gives me incorrect val.pdf
Will upvote asapPlease help my code gives me incorrect val.pdfWill upvote asapPlease help my code gives me incorrect val.pdf
Will upvote asapPlease help my code gives me incorrect val.pdf
 
Python Tidbits
Python TidbitsPython Tidbits
Python Tidbits
 
Practicle 1.docx
Practicle 1.docxPracticle 1.docx
Practicle 1.docx
 
Will upvote Please fix the following code and post your inputs and o.pdf
Will upvote Please fix the following code and post your inputs and o.pdfWill upvote Please fix the following code and post your inputs and o.pdf
Will upvote Please fix the following code and post your inputs and o.pdf
 
関数プログラミングことはじめ revival
関数プログラミングことはじめ revival関数プログラミングことはじめ revival
関数プログラミングことはじめ revival
 
Practical File Grade 12.pdf
Practical File Grade 12.pdfPractical File Grade 12.pdf
Practical File Grade 12.pdf
 
EcmaScript 6
EcmaScript 6 EcmaScript 6
EcmaScript 6
 
Fix this code so that it will run with proper answers, please dont u.pdf
Fix this code so that it will run with proper answers, please dont u.pdfFix this code so that it will run with proper answers, please dont u.pdf
Fix this code so that it will run with proper answers, please dont u.pdf
 

Recently uploaded

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 

Recently uploaded (20)

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 

New microsoft office word document

  • 1.
  • 2. Name: Rudra pratap singh Roll NO : Class : Xll SCI SCHOOL : A.P.S ACADEMY This is to cerify that the bonafide work of F.I.T (Practical / Project) has been done by the student as per CBSE requirement during the academic session : 2019-2020 Examiner’s signature Teacher – In – charge Date HEAD OF INSTITUTION
  • 3. I WOULD LIKE TO EXPRESS MY SPECIAL THANKS OF GRATITUDE TO MY TEACHER MRS. DEEPIKA MULLICK AS WELL AS OUR PRINCIPAL MRS. HEMA KALAKOTI WHO GAVE ME THE GOLDEN OPPORTUNITY TO DO THIS WONDERFUL PROJECT ON THE TOPIC GAMEING PROGRAM WHICH ALSO HELPED ME IN DOING A LOT OF RESEARCH AND I COME TO KNOW ABOUT SO MANY NEW THINGS I AM REALLY THANKFUL TO THEM. SECONDLY I WOULD ALSO LIKE TO THANK MY PARENTS AND FRIENDS WHO HELPED ME A LOT IN FINALIZING THIS PROJECT WITHIN THE LIMITED TIME FRAME.
  • 4.
  • 5. importrandom importcollections random.seed(1) size = 5 bombs = collections.defaultdict(int) counts = collections.defaultdict(int) display = collections.defaultdict(lambda: 'X') neighbors = sorted(set((i, j) for i in range(size) for j in range(size)) - {(0, 0)}) # Initialize for x in range(size): for y in range(size): bombs[x, y] = 0 counts[x, y] = 0 display[x, y] = '?' # Set bombs for _ in range(3): x = random.randrange(size) y = random.randrange(size) bombs[x, y] = 1 # Calculate counts for x in range(size): for y in range(size): total = 0 for i in [-1, 0, 1]: for j in [-1, 0, 1]: total += bombs[x + i, y + j]
  • 6. counts[x, y] = total def show(grid): for x in range(size): for y in range(size): print(grid[x, y], end=', ') print() print('Bombs:') show(bombs) print('Counts:') show(counts) alive = True def reveal(x, y): if bombs[x, y]: return False display[x, y] = counts[x, y] if counts[x, y]: return True zeros = [ (x, y) ] while zeros: x, y = zeros.pop() if not ((0 <= x < size) and (0 <= y < size)): continue if counts[x, y] == 0: display[x, y] = 0 for i in (-1, 0, 1): for j in (-1, 0, 1):
  • 7. if i == j == 0: continue offset_x = x + i offset_y = y + j seen = display[offset_x, offset_y] != '?' if counts[offset_x, offset_y] == 0 and notseen: zeros.append((offset_x, offset_y)) return True while alive: show(display) x = int(input('row: ')) y = int(input('column: ')) alive = reveal(x, y) if not alive or not any(spot== '?' for spotin display.values()): break if alive: print('Congratulations!You win.') else: print('Sorry, you failed.') ---------------------------------------------------------------------------------------------------- -------------------------
  • 8.
  • 9.
  • 10.
  • 11. importatexit importcollections importitertools importrandom importsqlite3 importthreading importtime importconsole original_terminal_state = console.get_terminal_mode() atexit.register(console.set_terminal_mode, original_terminal_state) class Game: "Game state for Tetris." def __init__(self, width, height, seed=None): self.random = random.Random(seed) self.width= width self.height = height self.board = collections.defaultdict(lambda: '#') for x in range(width): for y in range(height): self.board[x, y] = ' ' self.active = True self.speed = 20 self.next_letter = self.random.choice('IJLOSTZ') self.piece = self.next_piece() self.score = 0 self.stash = None def draw(self): "Draw game state." print('Score:', self.score, end='rn') print('Level:', self.score// 4 + 1, end='rn') print('Nextpiece:', self.next_letter, end='rn') print('Stash piece:', 'no' if self.stash is Noneelse 'yes', end='rn') print('*' * (self.width + 2), end='rn')
  • 12. for y in range(self.height): print('|', end='') for x in range(self.width): if (x, y) in self.piece: print('@', end='') else: print(self.board[x, y], end='') print('|', end='rn') print('*' * (self.width + 2), end='rn') def next_piece(self): "Create a new piece, on collision set active to False." letter = self.next_letter self.next_letter = self.random.choice('IJLOSTZ') if letter == 'I': piece = {(0, 0), (0, 1), (0, 2), (0, 3)} elif letter == 'J': piece = {(1, 0), (1, 1), (1, 2), (0, 2)} elif letter == 'L': piece = {(0, 0), (0, 1), (0, 2), (1, 2)} elif letter == 'O': piece = {(0, 0), (0, 1), (1, 0), (1, 1)} elif letter == 'S': piece = {(0, 1), (1, 0), (1, 1), (2, 0)} elif letter == 'T': piece = {(0, 0), (1, 0), (2, 0), (1, 1)} else: assert letter == 'Z' piece = {(0, 0), (1, 0), (1, 1), (2, 1)} offset = self.width // 2 - 1 piece = {(x + offset, y) for x, y in piece} if self.collide(piece): self.end() return piece def end(self): self.active = False print('Gameover!Pressany key to quit.', end='rn')
  • 13. def tick(self, mark): "Notify the game of a clock tick." if mark % self.speed == 0: moved = self.move_piece(0, 1) if not moved: for x, y in self.piece: self.board[x, y] = '#' self.collapse() self.piece = self.next_piece() self.draw() def collapse(self): "Collapse fulllines." y = self.height - 1 while y >= 0: full_line= all(self.board[x, y] == '#' for x in range(self.width)) if full_line: z = y while z > 0: for x in range(self.width): self.board[x, z] = self.board[x, z - 1] z -= 1 for x in range(self.width): self.board[x, 0] = ' ' self.score += 1 if self.score % 4 == 0: self.speed -= 1 else: y -= 1 def collide(self, piece): "Check whether piece collides with others on board." return any(self.board[x, y] != ' ' for x, y in piece) def move_piece(self, x, y): "Movepiece by delta x and y." new_piece= {(a + x, y + b) for a, b in self.piece} if self.collide(new_piece): return False
  • 14. self.piece = new_piece return True def rotate_piece(self): "Rotate piece." min_x = min(xfor x, y in self.piece) max_x = max(x for x, y in self.piece) diff_x = max_x - min_x min_y = min(y for x, y in self.piece) max_y = max(y for x, y in self.piece) diff_y = max_y - min_y size = max(diff_x, diff_y) new_piece= set() for x, y in self.piece: pair = (min_x + size) - (y - min_y), min_y + (x - min_x) new_piece.add(pair) if self.collide(new_piece): return False self.piece = new_piece return True def move(self, key): "Update game state based on key press." if key == 'left': moved = self.move_piece(-1, 0) elif key == 'right': moved = self.move_piece(1, 0) elif key == 'down': moved = self.move_piece(0, 1) elif key == 'up': moved = self.rotate_piece() elif key == 'swap': if self.stash is None: self.stash = self.piece self.piece = self.next_piece() else: self.piece, self.stash = self.stash, self.piece if self.collide(self.piece): self.end()
  • 15. moved = True else: assert key == 'space' moved = self.move_piece(0, 1) while moved: moved = self.move_piece(0, 1) moved = True if moved: self.draw() def draw_loop(game): game.draw() counter = itertools.count(start=1) while game.active: mark = next(counter) game.tick(mark) time.sleep(0.1) def input_loop(game): """Input loop. Handlekeyboard inputin a separate thread. """ while game.active: key = console.get_input() if key is None: continue elif key == 'quit': game.active = False else: assert key in ('left', 'down', 'right', 'up', 'space', 'swap') game.move(key) console.set_terminal_mode(original_terminal_state) print('Enter your namefor leaderboard (blank to ignore):') name = input()
  • 16. if name: con = sqlite3.connect('tetris.sqlite3', isolation_level=None) con.execute('CREATE TABLE IFNOT EXISTS Leaderboard (name, score)') con.execute('INSERTINTO Leaderboard VALUES (?, ?)', (name, game.score)) scores = con.execute('SELECT* FROM Leaderboard ORDER BY score DESC LIMIT 10') print('{0:<16}| {1:<16}'.format('Name', 'Score')) for pair in scores: print('{0:<16}| {1:<16}'.format(*pair)) def main(): "Main entry-pointfor Tetris." game = Game(10, 10) draw_thread = threading.Thread(target=draw_loop, args=(game,)) input_thread = threading.Thread(target=input_loop, args=(game,)) draw_thread.start() input_thread.start() draw_thread.join() input_thread.join() if __name__ == '__main__': main() ---------------------------------------------------------------------------------------------------
  • 17.
  • 18.
  • 19. import time from time import sleep import random sus="-"*35 depo=["rock","paper","scissors"] while True: x=input("rock , paper, scissors: ") if x not in depo: print ("Dontcheat!") continue pc=random.choice(depo) sleep(0.5) print (("Computer picked {}.").format(pc)) if x==pc: sleep(0.5) print (("nIt's a draw.n{}").format(sus)) elif x=="rock" and pc=="scissors": sleep(0.5) print (("nYou win.rock beats scissorsn{}").format(sus)) elif x=="paper" and pc=="rock": sleep(0.5) print (("nYou win.paper beats rockn{}").format(sus)) elif x=="scissors" and pc=="paper": sleep(0.5) print (("nYou win.scissors beats papern{}").format(sus)) else: sleep(0.5) print (("nYou lose. {} beats {}n{}").format(pc,x,sus)) input()