Sign Ratios
This kind of check helps you quickly understand the makeup of your data: how many values are above zero, below zero, or exactly zero. The function plus_minus receives a list of integers arr. Return a list of three ratios: positive values, negative values, and zeroes, with each ratio rounded to 6 decimal places.
Примеры
Ввод
[-4, 3, -9, 0, 4, 1]Вывод
[0.5, 0.333333, 0.166667]Ввод
[1, 2, 3]Вывод
[1, 0, 0]Ввод
[-1, -2, -3, -4]Вывод
[0, 1, 0]Нужно реализовать
def plus_minus(arr: list[int]) -> list[float]:
Теги
arraymath
Log in om je inzendingsgeschiedenis te zien
InloggenLog in om de AI-mentor te gebruiken
InloggenVisible tests
1
Input
[-4,3,-9,0,4,1]Expected
[0.5,0.333333,0.166667]2
Input
[1,2,3]Expected
[1,0,0]3
Input
[-1,-2,-3,-4]Expected
[0,1,0]4
Input
[0,0]Expected
[0,0,1]5
Input
[1,-1,0,1]Expected
[0.5,0.25,0.25]6
Input
[-1]Expected
[0,1,0]Focus radio
Paused · SomaFM · Fluid