+ 1
i take it we are finding random integers within 1 and 6 here? also is random a real module or just used as an example for us to
import random for i in range(5): value = random.randint(1, 6) print(value) Result: >>> 2 3 6 5 4 >>>
3 Respostas
+ 1
random is a real module in Python, used to generate pseudo random numbers. In this example, a random number between 1 and 6 is generated and printed to the console five times. In fact, random.randint is used to find a random number.
0
example
0
random is a real module in Python with atleast very 3 useful methods:
choice: takes 1 iterable as an argument and randomly selects an item from it.
randint: takes 2 integers as arguments and randomly selects any integer between the 2 integers.
random: takes no arguments and randomly selects any float between 0 and 1.