mirror of
https://github.com/metafy-social/python-scripts.git
synced 2024-11-27 14:01:12 +00:00
commit
c21f722518
10
scripts/Dice Roll/main.py
Normal file
10
scripts/Dice Roll/main.py
Normal file
|
@ -0,0 +1,10 @@
|
|||
import random
|
||||
b=input("Do you want to roll the dice?y/n: ")
|
||||
if b=='y':
|
||||
a=int(input("Number of times you want to roll: "))
|
||||
print("Result: ")
|
||||
for i in range(0,a):
|
||||
ans=random.randint(1,6)
|
||||
print(i+1,".",ans)
|
||||
else:
|
||||
print("Good Bye!")
|
5
scripts/Dice Roll/readme.md
Normal file
5
scripts/Dice Roll/readme.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
Dice Roll Game with PYTHON
|
||||
|
||||
#Steps :
|
||||
Run - python main.py
|
||||
Have a fun time!!
|
40
scripts/Tic-Tac-Toe/main.py
Normal file
40
scripts/Tic-Tac-Toe/main.py
Normal file
|
@ -0,0 +1,40 @@
|
|||
def check(m):
|
||||
if ( (m[0][0] == m[0][1] == m[0][2] != 0)
|
||||
or (m[1][0] == m[2][0] == m[0][0] != 0 )
|
||||
or (m[0][0] == m[1][1] == m[2][2] != 0)
|
||||
or (m[1][0] == m[1][2] == m[1][2] != 0)
|
||||
or (m[2][0] == m[2][1] == m[2][2] != 0)
|
||||
or (m[0][1] == m[1][1] == m[2][1] != 0)
|
||||
or (m[0][2] == m[1][2] == m[2][2] != 0)
|
||||
or (m[0][2] == m[1][1] == m[2][0] != 0) ):
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
|
||||
|
||||
def display(m):
|
||||
for i in range(3):
|
||||
for j in range(3):
|
||||
print(m[i][j],end = "\t")
|
||||
print("\n")
|
||||
|
||||
|
||||
a=input("Want to play tic-tac-toe?y/n: ")
|
||||
if a== "y":
|
||||
m = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
|
||||
while True:
|
||||
i,j= int(input("X: enter row no.")), int(input("enter column no."))
|
||||
m[i][j]="X"
|
||||
display(m)
|
||||
if check(m)== 1:
|
||||
print("Congratulations you won!")
|
||||
break
|
||||
|
||||
i,j= int(input("O: enter row no.")), int(input("enter column no."))
|
||||
m[i][j]="O"
|
||||
display(m)
|
||||
if check(m)== 1:
|
||||
print("Congratulations you won!")
|
||||
break
|
||||
else:
|
||||
print("Good Bye!")
|
5
scripts/Tic-Tac-Toe/readme.md
Normal file
5
scripts/Tic-Tac-Toe/readme.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
Tic Tac Toe with PYTHON
|
||||
|
||||
#Steps :
|
||||
Run - python main.py
|
||||
Have a fun time!!
|
Loading…
Reference in New Issue
Block a user