-2

I want to define a variable s which can only take real values between 0 and 1 in python, how to write the code for it.

Sajan
  • 1,219
  • 1
  • 4
  • 12
  • Does this answer your question? [How to get a random number between a float range?](https://stackoverflow.com/questions/6088077/how-to-get-a-random-number-between-a-float-range) – Niranjan Kumar Apr 23 '20 at 05:10

1 Answers1

0

Use Random library:

import random
s = random.random() # the default range is [0,1)
Joshua
  • 4,917
  • 1
  • 10
  • 33