Challenge: Random Number Generator
Tehtävä
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.
Ratkaisu
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 2. Luku 6
single
Kysy tekoälyä
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme
Mahtavaa!
Completion arvosana parantunut arvoon 5.56
Challenge: Random Number Generator
Pyyhkäise näyttääksesi valikon
Tehtävä
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.
Ratkaisu
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 2. Luku 6
single