• 6 heures
  • Facile

Ce cours est visible gratuitement en ligne.

course.header.alt.is_video

course.header.alt.is_certifying

J'ai tout compris !

Mis à jour le 21/01/2021

Practice managing program logic in Python

Connectez-vous ou inscrivez-vous gratuitement pour bénéficier de toutes les fonctionnalités de ce cours !

It's Your Turn!

Imagine your company has organized a friendly inter-colleague Python competition! Your task: Simulate a roulette game using Python.

How does roulette work?  

At a casino, the roulette wheel is composed of alternating red and black slots, each slot with its own number. Prior to spinning the wheel, a player place a bet on a roulette table. They start with a fixed amount of money and bets a small part of this amount at each spin.

The players objective is guess what number the roulette wheel will land on at each turn and, therefore, to win the most money. When the player has lost all his money, they are out of the game.

Simulate a roulette game in Python

  • The player bets on a single number between 0 and 49. While they chooses their number, they also choose the amount of money to play.

  • The script generates a random number in this range (0 - 49), simulating the roulette. If the output number is the same than the  number that was chosen (1/50 probability), then the player has won FIFTY times his bet!

  • If not, the player looses his bet and can try again in the next round.  

  • If the user is running out of money, the script stops and displays that he has lost.

Further instructions

You will have some checkups to run:

  • When the player bets an amount of money, you have to check to ensure this corresponds with the amount of money the player has left. You also have to check that this amount is greater than 0. You will ask him as long as these conditions are not met.

  • When the player bets a number, the program has to check that the number is between 0 and 49.

Deliverable

  • You will provide your program in a Jupyter notebook format. Make sure that one loop statement has been used in addition to a conditional structure (if/else).

Check Your Work

Exemple de certificat de réussite
Exemple de certificat de réussite