import statistics
import typing
from typing import Callable
def Transform(predicate: Callable[[int], bool], Array:list, NewValue: int):
for index, item in enumerate(Array):
if predicate(item):
Array[index] = NewValue
return Array
def ReadSeq(Len):
for _ in range(Len):
yield int(input())
def main():
seq = list(ReadSeq(10))
average = statistics.mean(seq)
TSeq = Transform(lambda p: p > average, seq, 1)
print(*TSeq)
if __name__ == '__main__':
main()
Объяснение:
import statistics
import typing
from typing import Callable
def Transform(predicate: Callable[[int], bool], Array:list, NewValue: int):
for index, item in enumerate(Array):
if predicate(item):
Array[index] = NewValue
return Array
def ReadSeq(Len):
for _ in range(Len):
yield int(input())
def main():
seq = list(ReadSeq(10))
average = statistics.mean(seq)
TSeq = Transform(lambda p: p > average, seq, 1)
print(*TSeq)
if __name__ == '__main__':
main()
Объяснение: