Write a Python program to shuffle the following elements randomly


The program uses the random module in Python to shuffle the elements of a list nums.

  • nums is a list of integers ranging from 10 to 100 with a step of 10.
  • random.shuffle(nums) shuffles the elements of the list in place.
  • print(nums) prints the shuffled list to the console.

So, each time the program runs, the elements of the list nums are shuffled randomly and printed to the console. The output will be a shuffled list of the integers ranging from 10 to 100 with a step of 10.

Source Code

import random
 
nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
random.shuffle(nums)
print(nums)

Output

[30, 50, 70, 60, 10, 100, 40, 90, 80, 20]

Example Programs