Python - Standard Library Usage
Which of the following is the correct way to import the
random module and use choice to pick a random element from a list items?random module and use choice to pick a random element from a list items?choice, you must import the random module fully or import choice specifically. import random; random.choice(items) imports the module correctly.random.choice(items), which is correct. from random import randint; choice(items) imports randint but tries to call choice without import. import random.choice; choice(items) has invalid import syntax. import random; random.randint(items) calls randint with a list, which is incorrect.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions