Write a random number generator that generates random numbers between 1 and 6 (simulates a dice)
- Details
- Category: 12th class computer practical's.
- Published: Friday, 11 June 2021 08:15
- Written by Super User
- Hits: 747
import random #to use randint function
print('simulation of a dice')
random_number=random.randint(1,6) #randint takes 2 parameters starting and end range to generate and return integers
print('its a ',random_number)
Explanation: We are importing random library from python. now we can access functions in random library. random_number is a variable which stores random integer returned by randint function. it takes 2 parameters starting and end integer. in last line we are printing the value we got.