Bird
0
0

Which of the following is the correct syntax to import the choice and shuffle functions from the random module?

easy📝 Syntax Q12 of 15
Python - Modules and Code Organization
Which of the following is the correct syntax to import the choice and shuffle functions from the random module?
Afrom random import choice, shuffle
Bimport random.choice, random.shuffle
Cimport choice, shuffle from random
Dfrom random import (choice shuffle)
Step-by-Step Solution
Solution:
  1. Step 1: Recall correct import syntax for multiple items

    To import multiple items, use from module import item1, item2 separated by commas.
  2. Step 2: Check each option

    from random import choice, shuffle matches the correct syntax: from random import choice, shuffle.
  3. Final Answer:

    from random import choice, shuffle -> Option A
  4. Quick Check:

    Multiple imports use commas inside from-import [OK]
Quick Trick: Use commas to import multiple items from a module [OK]
Common Mistakes:
  • Using 'import module.item' syntax incorrectly
  • Placing 'from' after 'import'
  • Using parentheses without commas

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes