Computer Science, asked by shanka2816, 8 months ago

What value will be return by ""choice(seq)"" ?

Answers

Answered by BrainlyYoda
7

Answer:

choice(seq) will return a random value or item from a sequence such as a list, tuple or string.

Extra Information:

choice() function =>

1. This function is built-in Python programming language.

2. To use this function you have to import random module in your code.

3. Syntax for choice() function => random.choice(sequence)

Let's look at a Python program for our understanding.

import random                      #random module is imported

list = [11, 22, 33, 44, 55, 66]             #It is a list containing various items

print(random.choice(list))  

 

Output of the Python program can be any item from the given list such as it can be 11 or 22 or 33 or 44 or 55 or 66. Every time you run it will give different output.

The application of this function is that it can be used in lucky draws, or some guessing games etc.

Answered by mad210202
0

Answer:

This is a python programming function that returns a random value in the item list.

Explanation:

Choice(seq) - It is an inbuilt Function in python programming language.

It is used to return the random value from the item of the list, tuple or string.

Syntax:

random.choice(sequence)

Parameters used for this function:

Sequence in this function is a mandatory parameter that  can be a list, tuple, or string.

Returns:  

The choice() returns a random item.

Similar questions