Write a programming task in the following format: "Title": "[Название…
- User
Assistant: User: Write a programming task in the following format:
"Title": "[Название задачи]", "Task Description": "[Краткое описание задачи, что требуется сделать]", "Function Signature": "def имя функции -> [тип возвращаемого значения]:"
Please make sure to only provide the title, task description, and function signature, without examples, constraints, or detailed explanations.
Also, provide a solution for the task in Python code in the following format:
"Solve": "[Решение задачи на Python]"
Provide three examples of input and output in the following format: "Examples": [ "Example 1: Input: [Пример входных данных] Output: [Пример выходных данных]", "Example 2: Input: [Пример входных данных] Output: [Пример выходных данных]", "Example 3: Input: [Пример входных данных] Output: [Пример выходных данных]" ]
Please follow this format exactly, without any additional explanations or comments.
Assistant:
- Assistant
"Title": "Calculate Average of Positive Numbers", "Task Description": "Develop a function that takes a list of integers and returns the average of all positive numbers in the list. If there are no positive numbers, return 0.", "Function Signature": "def average_positive(numbers: List[int]) -> float:"
"Solve": """ def average_positive(numbers: List[int]) -> float: positive_numbers = [num for num in numbers if num > 0] if not positive_numbers: return 0.0 return sum(positive_numbers) / len(positive_numbers) """
"Examples": [ "Example 1: Input: [1, -2, 3, 4, -5] Output: 2.6666666666666665", "Example 2: Input: [-1, -2, -3] Output: 0.0", "Example 3: Input: [10, 20, 30] Output: 20.0" ]