Give an example of ""choice()""
Answers
Answered by
4
Explanation:
Hope you like it
Thank you
Attachments:
Answered by
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
Math,
5 months ago
Hindi,
5 months ago
Political Science,
5 months ago
Computer Science,
9 months ago
Computer Science,
9 months ago
Chemistry,
1 year ago
English,
1 year ago