choice() is an inbuilt function in Python programming language that returns a random item from a list, tuple, or string.
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.
Print any random number 5 times from a given list.
The output changes every time as choice() function is used.
1 4 1 5 7
- Python map function | Count total set bits in all numbers from 1 to n
- Random Numbers in Python
- Python | Add comma between numbers
- Python | N consecutive Odd or Even Numbers
- Python program to add two numbers
- Python | Check whether string contains only numbers or not
- Python | Extract numbers from string
- Complex Numbers in Python | Set 1 (Introduction)
- Python | Average of Float Numbers
- Python | Indices of numbers greater than K
- Python - Random Numbers Summation
- Python | Numbers in a list within a given range
- Python program to count Even and Odd numbers in a List
- Python - Descending Sort String Numbers
- Python | Create list of numbers with given range
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.