![]() |
Syntax: random.choice(sequence) Parameters: sequence is a mandatory parameter that can be a list, tuple, or string. Returns: The choice() returns a random item. Note:We have to import random to use choice() method. Below is the Python3 implementation of the above approach:
The output every-time will be different as the system returns a random item. 5 s Practical application:
The output changes every time as choice() function is used. 1 4 1 5 7 |
Reffered: https://www.geeksforgeeks.org
Python |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 18 |