A Program to Generate a Random Number

In this example, we are giving a program to generate a random number.


Program to swap to generate a random number:

  1. # Generate a random number
  2. import random
  3. print(random.randint(0,9))

Output:

8