Write a Python program to randomly select an item from a list


This is a simple Python program that randomly selects an element from the list book and prints it to the console. The random module is first imported to generate a random number. The list book contains several programming languages, and random.choice(book) returns a randomly selected element from the list book.

The selected programming language is then printed to the console using the print() function. In summary, this program randomly selects and prints a programming language from the list book.

Source Code

import random
book = ["C","C++","JAVA","PYTHON","MYSQL","PHP"]
print(random.choice(book))

Output

MYSQL

Example Programs