Flowchart to Python Code – Poker Dice Game

The aim of this challenge is to create a simplified game of Poker Dice using only three dice.
The computer will generate three random numbers between 1 and 6.

The program will then check to see if the three dice have the same value (“Three of a kind!”) or if any two of the three dice have the same value (“Pair”).

The game will be implemented using the following algorithm:
flowchart-poker-dice

This algorithm is a good example of:
selection-label

Extension Task


Could you improve your code further to find out if:

  • The 3 dice are all even numbers.
  • The 3 dice are all odd numbers.

Tip:
To find out if a die number is even you could check whether it is equal to 2, 4 or 6.

Pseudocode:

IF (die1==2 OR die1==4 OR die1==6) AND (die2==2 OR die2==4 OR die2==6) AND (die2==2 OR die2==4 OR die2==6) THEN
   DISPLAY("You have three even numbers.")
END IF

Another method would be to use [lists] and the keyword “in“:

Pseudocode:

IF die1 in [2,4,6] AND die2 in [2,4,6] AND die3 in [2,4,6]  THEN
   DISPLAY("You have three even numbers.")
END IF
unlock-access

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area

Did you like this challenge?

Click on a star to rate it!

Average rating 3.8 / 5. Vote count: 18

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!

Tagged with: ,