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:

from random import randint

#to generate a random number between 1 and 10 use the following instruction:
myNumber = randint(1,10)

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.

def isOdd(number):
    if (number % 2 == 1):
    	return True
        return False

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:



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.3 / 5. Vote count: 13

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

As you found this challenge interesting...

Follow us on social media!

Tagged with: ,