2.3.4.5.
There are many ways to generate random numbers in Python. One method is to use the random module.
The random module contains functions that can be used to generate random numbers. The most commonly used function is randint().
randint() takes two arguments, the first argument is the lower limit and the second argument is the upper limit. It will return a number between the two limits.
For example, if you want to generate a random number between 0 and 9, you can use the following code:
import random print(random.randint(0,9))
Another function that can be used to generate random numbers is uniform(). The uniform() function takes one argument, the lower limit. It will return a number between 0 and the lower limit.
For example, if you want to generate a number between 0 and 5, you can use the following code:
import random print(random.uniform(0,5))
0 개의 댓글:
댓글 쓰기