Challenge: Random Number Generator
Task
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
Everything was clear?
Thanks for your feedback!
SectionΒ 2. ChapterΒ 6
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Awesome!
Completion rate improved to 5.56
Challenge: Random Number Generator
Swipe to show menu
Task
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
Everything was clear?
Thanks for your feedback!
SectionΒ 2. ChapterΒ 6
single