Python Programming - Standard Libraries - Discussion

Discussion Forum : Standard Libraries - General Questions (Q.No. 68)
68.
How can you use the random module in Python to generate a random integer between 1 and 10 (inclusive)?
random.randint(1, 10)
random.int(1, 10)
rand.randint(1, 10)
rand.random(1, 10)
Answer: Option
Explanation:
import random

# Example usage of random module
random_number = random.randint(1, 10)
print(f"Random number: {random_number}")
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.