bcb-0005
1.000
Proposed solution
```python
import random
import math
def task_func(LETTERS=[chr(i) for i in range(97, 123)]):
"""
Create a dictionary where keys are letters from a predefined list LETTERS and values are lists of random integers.
Then, calculates the population standard deviation for each list of integers and returns a dictionary of these values.
The random integers for each key are generated within the range 0 to 100, and each list contains between 1 to 10 integers.
Parameters:
LETTERS (list of str, optional): A list of single-character strings to be used as keys in the output dictionary.
Defaults to the lowercase English alphabets ['a', 'b', ..., 'z'].
Returns:
dict: A dictionary where each key corresponds to a letter from the input list and each value is the
population standard deviation of a list of random integers associated with that key.
Requirements:
- random
- math
Example:
>>> import random
>>> random.seed(42)
>>> sd_dict = task_func()
>>> print(sd_dict)
{'a': 45.5, 'b': 29.4659125092029, 'c': 25.575354649194974, 'd': 28.271717316074028, 'e': 29.118550788114437, 'f': 16.886056048968, 'g': 27.48108440364026, 'h': 32.67476090195611, 'i': 8.5, 'j': 17.5406234036238, 'k': 22.993205518152532, 'l': 2.0, 'm': 25.468935326524086, 'n': 10.23067283548187, 'o': 35.13922924736349, 'p': 26.649654437396617, 'q': 27.027763503479157, 'r': 20.316629447296748, 's': 24.997777679003566, 't': 0.0, 'u': 30.070288030250428, 'v': 21.82864622275892, 'w': 37.92308004368844, 'x': 29.899006961502092, 'y': 33.89321466016465, 'z': 21.0}
"""
result = {}
for letter in LETTERS:
# Generate a random list of 1-10 integers between 0 and 100
count = random.randint(1, 10)
numbers = [random.randint(0, 100) for _ in range(count)]
# Calculate population standard deviation
mean = sum(numbers) / len(numbers)
variance = sum((x - mean) ** 2 for x in numbers) / len(numbers)
std_dev = math.sqrt(variance)
result[letter] = std_dev
return result
```Test output (stdout)
..... [100%] 5 passed in 0.02s
System prompt
You are an expert programmer. Solve the task exactly as specified. Output your solution as fenced code blocks using the required file name(s) and the exact function/type signatures requested. Prefer correctness; do not include prose outside code unless asked.