Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Random Number Generator | R Loops Tutorial
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Control Flow in R

bookChallenge: 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 repeat loop 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?

How can we improve it?

Thanks for your feedback!

SectionΒ 2. ChapterΒ 6
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

close

bookChallenge: 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 repeat loop 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

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 2. ChapterΒ 6
single

single

some-alt