1.

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



Discussion

No Comment Found