random() function in python by R4R Team

- random() is a python function which is predefined in the random library.
- here both random are different thing,one random is library and another random is function.
- it will return the random float value in the range of 0 to 1.

program-

import random
print(random.random())
print(random.random())
print(random.random())
print(random.random())
print(random.random())
print(random.random())
print(random.random())
print(type(random.random()))
print(type(random.random()))
print(type(random.random()))


output-

0.7597306350978931
0.37316037207384156
0.7701398359379902
0.27269808567197074
0.8019154831626036
0.729824832622016
0.4140064411653034
<'class 'float'>
<'class 'float'>
<'class 'float'>


- In this program, firstly we import the random library by import random,
- print(random.random()) is print the random float value between the 0 and 1
- Here first random is a library and second random is a predefined function in random library.
Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!