-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,247
  • 1
  • 5
  • 13
  • 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 Varghese
  • 5,082
  • 1
  • 13
  • 34