RANDOM: Python can generate random numbers very easily and within specific ranges.

  • In the toolkit, drag Random Integer to the bottom. Change my_var to random_integer.
  • random.randint(1, 10) returns a number between 1 and 10! Change this range of numbers to 1 and 1000.
  • Drag out Random Float onto the next line and change my_var to random_float.
  • random.random() always returns a random decimal number between 0 and 1! Click Run a few times!

To navigate the page using the TAB key, first press ESC to exit the code editor.

# THIS ACTIVITY IS IN PREVIEW ONLY MODE
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)