Python is a simple, general purpose, high level, and object-oriented programming language.
Python is an interpreted scripting language also. Guido Van Rossum is known as the founder of Python programming.
==========================================================
Python Program to Generate a Random Number :
1.Generating a Random Number :
The random module provides a random() method which generates a float number between 0 and 1.
#code 1:
import random
n = random.random()
print(n)
2.Generating a Number within a Given Range
Python random module provides the randint() method that generates an integer number within a specific range. We can pass the two numbers as arguments that defines the range.
code 2:
import random
n = random.randint(0,50)
print(n)
3.Using random.sample()
The random module also provides the sample() method, which directly generates a list of random numbers. Below is the example of generating random numbers using the sample() method.
code 3:
import random
#Generate 5 random numbers between 10 and 30
random_list = random.sample(range(10, 40), 6)
print(random_list)
============================================================
#pythonprogram
#learnpython
#quadratic_equation
#Generate_a_Random_Number
#python_equation
#RandomNumber
========================================
Watch video Python Program to Generate a Random Number online without registration, duration hours minute second in high quality. This video was added by user CodeLSC 22 October 2021, don't forget to share it with your friends and acquaintances, it has been viewed on our site 46 once and liked it 1 people.