MENU
Question -

Give an example of “choice()”



Answer -

The following example shows the usage of choice( ) method.
# !/usr/bin/py thon
import random
print “choice([l, 2, 3, 5, 9]): “,
random.choice([l,2,3,5,9])
print “choice(‘A String*): “,
random.choice(‘A String’)

This will produce the following result choice

([l, 2, 3,5,9]): 2
choice(‘A String’) :n

Comment(S)

Show all Coment

Leave a Comment

Free - Previous Years Question Papers
Any questions? Ask us!
×