Computer Science, asked by pranjalkeshari262, 10 months ago

Give an example of ""choice()""

Answers

Answered by zeba09
4

Explanation:

Hope you like it

Thank you

Attachments:
Answered by laraibmukhtar55
0

Choice () function:

Python number method choice () returns an arbitrary item from a list, tuple, or string.

String of choice () function:

The syntax for choice () method is choice (seq).

Return value of choice () method:

This method returns a random item.

The subsequent example shows the application of choice() method.  

#!/usr/bin/python

import random

print "choice([1, 2, 3, 5, 9])

: ", random. Choice([1, 2, 3, 5, 9])

print "choice(A String) : ", random. choice(A String)

When we run above mentioned program, it creates following result −  

choice ([1, 2, 3, 5, 9]) : 2

choice (A String) : n

Similar questions