Fancy a game of Poker Dice?

diceThe 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 user scores points as follows:

  • Three of a kind: +50pts
  • Straight (e.g. 3,4,5): +30pts
  • Three odd numbers: +15pts
  • Three even numbers: +15pts
  • One pair: +10pts

Step 1: Using random numbers

Start your game by generating three random numbers and displaying these to the end user.
You will need to import the randint function from the random python library. To do so you can use the following code:

Step 2: Odd or Even?

Think about the characteristic of an odd number aka a number which cannot be divided evenly by 2.

Using the mod (remainder: % sign in Python) we can determine if a number can be divided evenly by 2.

Based on this we can create a function (sub routine) called isOdd that will take a number as a parameter and return True if this number is odd, False if not.

Try this yourself or check the following code.

Can you make up another function to findout if a number is even?

Step 3: Complete the game…

You will need to reuse the two functions, isOdd() and isEven() that you created in the previous step.

Complete the code

Check the code below and complete it further:

Share Button
Posted in Computer Science, Python - Intermediate, Python Challenges Tagged with: ,

Our Latest Book