Challenge: Random Number Generator
Tâche
Swipe to start coding
Write a function that generates random numbers between 0 and 1 until one is greater than 0.95, returning the number of attempts needed.
- Start a counter for the number of attempts.
- Use a
repeatloop to generate a random number between 0 and 1. - If the random number is greater than 0.95, exit the loop.
- Return the total number of attempts.
Solution
Tout était clair ?
Merci pour vos commentaires !
Section 2. Chapitre 6
single
Demandez à l'IA
Demandez à l'IA
Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion
Génial!
Completion taux amélioré à 5.56
Challenge: Random Number Generator
Glissez pour afficher le menu
Tâche
Swipe to start coding
Write a function that generates random numbers between 0 and 1 until one is greater than 0.95, returning the number of attempts needed.
- Start a counter for the number of attempts.
- Use a
repeatloop to generate a random number between 0 and 1. - If the random number is greater than 0.95, exit the loop.
- Return the total number of attempts.
Solution
Tout était clair ?
Merci pour vos commentaires !
Section 2. Chapitre 6
single