Random Function
What is random function in Python💭?
Random function is use to take the random value
For Example:
If you want to print random value between (0 to 20) at every execution Follow these steps:
1-First import random .
2-Take any variable suppose I take "num" as a variable.
3-write num = random.randint(and write range in it) suppose I take from 0 to 20
The randint() method returns an integer number selected element from the specified range.
4-Then print variable
Here is the program:
import random
num = random.randint(0,20)
print(num)
output:
18 Note:(output is different at every execution)