Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
h-leth authored Apr 18, 2021
0 parents commit 07ad076
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 0 deletions.
38 changes: 38 additions & 0 deletions dice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import os
import time
from random import randint
from dices import dices


def roll_dice():
n = 0
while n < 3:
dice = randint(1, 6)
os.system('clear')
if dice == 1:
dices.one()
if dice == 2:
dices.two()
if dice == 3:
dices.three()
if dice == 4:
dices.four()
if dice == 5:
dices.five()
if dice == 6:
dices.six()
time.sleep(.400)
n += 1


keep_rolling = True
while keep_rolling:
user_input = input("\nRoll the dice (y/n): ")
if user_input.lower() == 'y':
roll_dice()
elif user_input.lower() == 'n':
keep_rolling = False
os.system('clear')
print("\nHave a nice day!!")
else:
print("\nWrong input type (y)es to roll again or (n)o to exit")
86 changes: 86 additions & 0 deletions dices.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
class dices:
'''Graphical versions of the six sides of a dice'''

def one():
'''Prints the value one of the dice.'''
print("""
--------------
| |
| |
| |
| ## |
| ## |
| |
| |
| |
--------------""")

def two():
'''Prints the value one of the dice.'''
print("""
--------------
| ## |
| ## |
| |
| |
| |
| |
| ## |
| ## |
--------------""")

def three():
'''Prints the value one of the dice.'''
print("""
--------------
| ## |
| ## |
| |
| ## |
| ## |
| |
| ## |
| ## |
--------------""")

def four():
'''Prints the value one of the dice.'''
print("""
--------------
| ## ## |
| ## ## |
| |
| |
| |
| |
| ## ## |
| ## ## |
--------------""")

def five():
'''Prints the value one of the dice.'''
print("""
--------------
| ## ## |
| ## ## |
| |
| ## |
| ## |
| |
| ## ## |
| ## ## |
--------------""")

def six():
'''Prints the value one of the dice.'''
print("""
--------------
| ## ## |
| ## ## |
| |
| ## ## |
| ## ## |
| |
| ## ## |
| ## ## |
--------------""")

0 comments on commit 07ad076

Please sign in to comment.