feat(curriculum): adding questions for dictionaries and sets quiz (#60396)

Co-authored-by: Dario-DC <105294544+Dario-DC@users.noreply.github.com>
Co-authored-by: Zaira <33151350+zairahira@users.noreply.github.com>
This commit is contained in:
Jessica Wilkins
2025-05-30 04:08:07 -07:00
committed by GitHub
parent 7ee3281428
commit 8fe6064013
@@ -17,439 +17,498 @@ To pass the quiz, you must correctly answer at least 18 of the 20 questions belo
#### --text--
Placeholder question
What is a dictionary?
#### --distractors--
Placeholder distractor 1
A data structure that only holds strings and lists.
---
Placeholder distractor 2
A data structure that is a collection of key-value pairs that only accept large numbers.
---
Placeholder distractor 3
A data structure that only holds a collection of tuples.
#### --answer--
Placeholder answer
A data structure that is a collection of key-value pairs.
### --question--
#### --text--
Placeholder question
Which of the following is the correct syntax for a dictionary?
#### --distractors--
Placeholder distractor 1
```py
dictionary = {
<key1: value1>,
<key2: value2>
}
```
---
Placeholder distractor 2
```py
dictionary = {
(key1: value1),
(key2: value2)
}
```
---
Placeholder distractor 3
```py
dictionary = {
[key1: value1],
[key2: value2]
}
```
#### --answer--
Placeholder answer
```py
dictionary = {
key1: value1,
key2: value2
}
```
### --question--
#### --text--
Placeholder question
Which of the following is true about dictionaries?
#### --distractors--
Placeholder distractor 1
Keys must be at least two characters in length.
---
Placeholder distractor 2
Keys must include a special symbol.
---
Placeholder distractor 3
Keys must include at least one number.
#### --answer--
Placeholder answer
Keys must be unique.
### --question--
#### --text--
Placeholder question
Which of the following constructors can be used to create a dictionary?
#### --distractors--
Placeholder distractor 1
`diction()`
---
Placeholder distractor 2
`dic()`
---
Placeholder distractor 3
`dictionary()`
#### --answer--
Placeholder answer
`dict()`
### --question--
#### --text--
Placeholder question
Which of the following is the correct way to access a value from a dictionary?
#### --distractors--
Placeholder distractor 1
`dictionary<key>`
---
Placeholder distractor 2
`dictionary/key/`
---
Placeholder distractor 3
`dictionary{key}`
#### --answer--
Placeholder answer
`dictionary[key]`
### --question--
#### --text--
Placeholder question
Which of the following is the correct way to update a value in a dictionary?
#### --distractors--
Placeholder distractor 1
`pizza['name'] >> 'Margherita'`
---
Placeholder distractor 2
`pizza['name'] << 'Margherita'`
---
Placeholder distractor 3
`pizza['name'] == 'Margherita'`
#### --answer--
Placeholder answer
`pizza['name'] = 'Margherita'`
### --question--
#### --text--
Placeholder question
Which of the following methods can be used to retrieve a value associated with a key?
#### --distractors--
Placeholder distractor 1
`access()`
---
Placeholder distractor 2
`set()`
---
Placeholder distractor 3
`retrieve()`
#### --answer--
Placeholder answer
`get()`
### --question--
#### --text--
Placeholder question
What is a view object?
#### --distractors--
Placeholder distractor 1
A special object used to turn strings into dictionaries.
---
Placeholder distractor 2
A way to view the content of a dictionary only if the dictionary has two or more key-value pairs.
---
Placeholder distractor 3
A special object used to turn lists into dictionaries.
#### --answer--
Placeholder answer
A way to see the content of a dictionary without creating a separate copy of the data.
### --question--
#### --text--
Placeholder question
Which of the following methods returns a view object with all the key-value pairs in the dictionary?
#### --distractors--
Placeholder distractor 1
`lists()`
---
Placeholder distractor 2
`dictionaries()`
---
Placeholder distractor 3
`collections()`
#### --answer--
Placeholder answer
`items()`
### --question--
#### --text--
Placeholder question
Which of the following methods removes all of the key-value pairs from the dictionary?
#### --distractors--
Placeholder distractor 1
`empty()`
---
Placeholder distractor 2
`replace()`
---
Placeholder distractor 3
`remove()`
#### --answer--
Placeholder answer
`clear()`
### --question--
#### --text--
Placeholder question
What will be the output for the following code?
```py
products = {
'Laptop': 990,
'Smartphone': 600,
'Tablet': 250,
'Headphones': 70,
}
for product in products.items():
print(product)
```
#### --distractors--
Placeholder distractor 1
```py
<'Laptop', 990>
<'Smartphone', 600>
<'Tablet', 250>
<'Headphones', 70>
```
---
Placeholder distractor 2
```py
'Laptop', 990
'Smartphone', 600
'Tablet', 250
'Headphones', 70
```
---
Placeholder distractor 3
```py
['Laptop', 990]
['Smartphone', 600]
['Tablet', 250]
['Headphones', 70]
```
#### --answer--
Placeholder answer
```py
('Laptop', 990)
('Smartphone', 600)
('Tablet', 250)
('Headphones', 70)
```
### --question--
#### --text--
Placeholder question
Which of the following is true about sets?
#### --distractors--
Placeholder distractor 1
Sets are mutable and ordered in reverse.
---
Placeholder distractor 2
Sets are mutable and ordered.
---
Placeholder distractor 3
Sets are immutable and unordered.
#### --answer--
Placeholder answer
Sets are mutable and unordered.
### --question--
#### --text--
Placeholder question
Which of the following is the correct way to create a set?
#### --distractors--
Placeholder distractor 1
`my_set = (1, 2, 3, 4, 5)`
---
Placeholder distractor 2
`my_set = <1, 2, 3, 4, 5>`
---
Placeholder distractor 3
`my_set = [1, 2, 3, 4, 5]`
#### --answer--
Placeholder answer
`my_set = {1, 2, 3, 4, 5}`
### --question--
#### --text--
Placeholder question
Which of the following functions is used to create an empty set?
#### --distractors--
Placeholder distractor 1
`create_set()`
---
Placeholder distractor 2
`empty_set()`
---
Placeholder distractor 3
`sets()`
#### --answer--
Placeholder answer
`set()`
### --question--
#### --text--
Placeholder question
What will be output to the terminal?
```py
my_set = {1, 2, 3, 4, 5, 6}
my_set.add(5)
print(my_set)
```
#### --distractors--
Placeholder distractor 1
`SyntaxError`
---
Placeholder distractor 2
`RangeError`
---
Placeholder distractor 3
`{1, 2, 3, 4, 5, 5, 6}`
#### --answer--
Placeholder answer
`{1, 2, 3, 4, 5, 6}`
### --question--
#### --text--
Placeholder question
Which of the following methods checks if a set is a subset?
#### --distractors--
Placeholder distractor 1
`issub()`
---
Placeholder distractor 2
`isset()`
---
Placeholder distractor 3
`subset()`
#### --answer--
Placeholder answer
`issubset()`
### --question--
#### --text--
Placeholder question
Which of the following methods checks if two sets are disjoint?
#### --distractors--
Placeholder distractor 1
`joint()`
---
Placeholder distractor 2
`isjoint()`
---
Placeholder distractor 3
`disjoint()`
#### --answer--
Placeholder answer
`isdisjoint()`
### --question--
#### --text--
Placeholder question
What does the symmetric difference operator(`^`) do?
#### --distractors--
Placeholder distractor 1
It returns a new set with only the elements that the sets have in common.
---
Placeholder distractor 2
It finds the difference between the sets and updates the first set with that result.
---
Placeholder distractor 3
It returns a new set with the elements of the first set that are not in the other set.
#### --answer--
Placeholder answer
It returns a new set with the elements that are either on the first or the second set, but not both.
### --question--
#### --text--
Placeholder question
Which of the following built-in modules is used for generating random numbers?
#### --distractors--
Placeholder distractor 1
`set_random`
---
Placeholder distractor 2
`get_random`
---
Placeholder distractor 3
`rand`
#### --answer--
Placeholder answer
`random`
### --question--
#### --text--
Placeholder question
Which of the following modules is used for working with regular expressions?
#### --distractors--
Placeholder distractor 1
`regex`
---
Placeholder distractor 2
`reg`
---
Placeholder distractor 3
`r`
#### --answer--
Placeholder answer
`re`