NEW
Font size
Worksheets9 Weeks Test
Total questions: 16
Worksheet time: 32mins
What is the primary purpose of the `pickStudent` function?
To select a random student from all three lists
To allow the user to manually pick a student
To randomly select a student from a given list until the user stops
To sort the names in alphabetical order
How does the program determine which class list to use?
It randomly picks one of the three lists
The user inputs a number corresponding to a class
The program assigns a default class
The user types the full name of the class
What will happen if the user enters an invalid input in `pickClass()`?
The program will terminate
The program will ask the user to try again
The program will default to `SIMS3`
The program will print an error message
Which module is used to select a random student?
`math`
`random`
`randomize`
`choice`
What happens when the user types `'end'` in `pickStudent`?
The program terminates immediately
The program stops picking students and returns to `pickClass()`
The program prints "End" and continues
The program ignores the input and continues picking
Why does `pickStudent` use a `while True` loop?
To continuously allow the user to pick students until they type `'end'`
To run the function only once
To prevent errors from invalid input
To avoid calling the function again
Which of the following is a potential issue with the `DINO_BADDIES` list?
The names are not in alphabetical order
The last name entry `'day''drian'` might not be handled correctly
The list contains duplicate names
The list is too short
What is the purpose of `random.choice(class_name)`?
To return a random list from the three available lists
To return a random student name from a given list
To shuffle the class list
To select the last name in the list
How does the program ensure that the user selects a valid class?
By using a `try-except` block
By checking if the input is an integer
By calling `pickClass()` recursively if an invalid input is given
By using a loop to request valid input
What is a possible improvement to avoid infinite recursion in `pickClass()`?
Using a `while` loop instead of recursion
Removing the `else` statement
Changing the input prompt
Using a `break` statement
What is the output if the user types "Python"?
Welcome
Try again!
Error
Enter your password
What is the output
What character should be placed at the end of the function "def" line, after the parentheses?
Hashtag (#)
Colon(:)
Exclamation (!)
Dash (-)
What does the `random.choice()` function do?
Returns a random element from a list
Chooses a random number between 1 and 100
Generates a random choice between True and False
Selects a random key from a dictionary
Which data structure does this describe?
Ordered, changeable, duplicates allowed [ ]
List
Tuple
Set
Dictionary
