Python Project

Kwame94
SampleTemplate.pptx

DICE SIMULATOR

BY: IRVING V.

CSN 140

Midterm project

1

Objective

The purpose of this program is to use python code to simulate the rolling of dice to observe the different outcomes once code is executed on python.

D20:

Its the signature twenty-sided die for Dungeons and Dragons. Its the most often used die in the game and usually determines all the strategies and attacks which will be used during game play by players.

FLOWCHART:

Roll Dice Results

Input: “Rolling d20…”

Executing code:

If d20 == 1 “CRITICAL FAIL!”

elif d20 == 20 “CRITICAL HIT!”

ReRoll

Code on phycharm:

-First , I imported a random module. This will generate the random integers; we can use the randit function. Randint accepts two parameters: a lowest and a highest number.

- I used a while loop to use the die command repeatedly.

-The random.randint sets a random integer from 1 – 20 to our d20 variable.

-To interpret the definitive outcomes of the d20 (1 & 20)

Running the code = Results 1st 2nd

…Rolling 1’s are usually bad…

The end

9