Skip to content

Commit c21f722

Browse files
authored
Merge pull request metafy-social#461 from Asmita-Dutta/master
Dice Roll
2 parents 4eda20b + 2267dcf commit c21f722

File tree

4 files changed

+60
-0
lines changed

4 files changed

+60
-0
lines changed

scripts/Dice Roll/main.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import random
2+
b=input("Do you want to roll the dice?y/n: ")
3+
if b=='y':
4+
a=int(input("Number of times you want to roll: "))
5+
print("Result: ")
6+
for i in range(0,a):
7+
ans=random.randint(1,6)
8+
print(i+1,".",ans)
9+
else:
10+
print("Good Bye!")

scripts/Dice Roll/readme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Dice Roll Game with PYTHON
2+
3+
#Steps :
4+
Run - python main.py
5+
Have a fun time!!

scripts/Tic-Tac-Toe/main.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
def check(m):
2+
if ( (m[0][0] == m[0][1] == m[0][2] != 0)
3+
or (m[1][0] == m[2][0] == m[0][0] != 0 )
4+
or (m[0][0] == m[1][1] == m[2][2] != 0)
5+
or (m[1][0] == m[1][2] == m[1][2] != 0)
6+
or (m[2][0] == m[2][1] == m[2][2] != 0)
7+
or (m[0][1] == m[1][1] == m[2][1] != 0)
8+
or (m[0][2] == m[1][2] == m[2][2] != 0)
9+
or (m[0][2] == m[1][1] == m[2][0] != 0) ):
10+
return 1
11+
else:
12+
return 0
13+
14+
15+
def display(m):
16+
for i in range(3):
17+
for j in range(3):
18+
print(m[i][j],end = "\t")
19+
print("\n")
20+
21+
22+
a=input("Want to play tic-tac-toe?y/n: ")
23+
if a== "y":
24+
m = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
25+
while True:
26+
i,j= int(input("X: enter row no.")), int(input("enter column no."))
27+
m[i][j]="X"
28+
display(m)
29+
if check(m)== 1:
30+
print("Congratulations you won!")
31+
break
32+
33+
i,j= int(input("O: enter row no.")), int(input("enter column no."))
34+
m[i][j]="O"
35+
display(m)
36+
if check(m)== 1:
37+
print("Congratulations you won!")
38+
break
39+
else:
40+
print("Good Bye!")

scripts/Tic-Tac-Toe/readme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Tic Tac Toe with PYTHON
2+
3+
#Steps :
4+
Run - python main.py
5+
Have a fun time!!

0 commit comments

Comments
 (0)