-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creating A Rolling Dice mechanism with Random Module
The user will inputing the number between 1 and 6 and the program will generate a result of the dice in a list
- Loading branch information
Showing
3 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Python: Current File", | ||
"type": "python", | ||
"request": "launch", | ||
"program": "${file}", | ||
"console": "integratedTerminal", | ||
"justMyCode": true | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"python.testing.pytestArgs": [ | ||
"." | ||
], | ||
"python.testing.unittestEnabled": false, | ||
"python.testing.pytestEnabled": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Import Module Section | ||
import random | ||
|
||
# Constant | ||
DICE = {1, 2, 3, 4, 5, 6} | ||
|
||
|
||
# Main Program | ||
def main(): | ||
num_dice_count = input("How much dice you want to roll? : ") | ||
num_dice = parse_input(num_dice_count) | ||
|
||
print(roll_dice(num_dice)) | ||
|
||
|
||
# Determine The input | ||
def parse_input(input_string): | ||
if int(input_string) in DICE: | ||
return int(input_string) | ||
else: | ||
print("Please enter a number between 1 and 6") | ||
raise SystemExit(1) | ||
|
||
|
||
# Rolling the dice with random module | ||
def roll_dice(num_dice): | ||
roll_result = [] | ||
for i in range(num_dice): | ||
a = random.randint(1, 6) | ||
roll_result.append(a) | ||
return roll_result | ||
|
||
|
||
# Generating Ascii Letters for Text-based user Interface | ||
def generate_face_dices_diagram(): | ||
pass | ||
|
||
|
||
main() |