python_exp8_sem4
python_exp8_sem4
Aim: Write a program to generate a series of unique random number by using random
module.
Theory:
The random module in Python is used to generate random numbers. It provides various
functions to generate random integers, floating-point numbers, and unique values. Below are
some key functions of the random module:
1. random.seed(a)
• Returns a random integer within a specified range, excluding the stop value.
• The step parameter allows selecting values at specific intervals.
• Example: random.randrange(10, 50, 5) → Possible outputs: 10, 15, 20, ..., 45.
4. random.randint(start, end)
Source Code:
import random
random.seed(10)
print(random.random())
print(random.randrange(3,25,4))
print(random.randint(3, 9))
Conclusion:
In this experiment, I learned how Python's random module creates random numbers. Using
seed(), randrange(), random(), and randint(), I saw how numbers can be controlled and
repeated when needed.