Question: PYTHON CODE random.choicellist) returns a single item from the list, tuple or string at random. random.samplellist o) returns a new list of n items randomly

PYTHON CODE  PYTHON CODE random.choicellist) returns a single item from the list, tuple
or string at random. random.samplellist o) returns a new list of n

random.choicellist) returns a single item from the list, tuple or string at random. random.samplellist o) returns a new list of n items randomly chosen from the list, tuple or string tandom shutlellist) randomly reorders all of the items in the list and changes the list itself. The list must be a mutable object so this will not work with strings or tuples. m) returns a randomly selected number between m and n as long as mcen. m and n are included in the possible return values There are other methods that you can look at on your own but these should be all you will need for this assignment. A complete sample program might be: import random elements I'earthLairifire'water) print(random.choice elements) print(random.samplelelements,2) tandom sbufflelelements) print(elements) or: from random import choise.sample,sbutfle.randint if you want to avoid using random. each time print(choice(elements) print(sample(elements,2) shuffle(elements) trying to use printpandom.shuflefelements) results in None because shuffle doesn't return anything. print(random.randint(1,5) print(randint(1,5) The output in either case might be: water l'air.'earthl

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!