N = int(input())
s = 0
k = 0
sr = 0
while N != 0:
s += N
k += 1
sr = s/k
print('Количество введённых чисел - ',k)
print('Среднее арифметическое введённых чисел = ',sr)
Ответ:
//Python 3.8.3
from typing import Callable, Any, Iterable
import statistics
def ReadSeqIntWhile(predicate: Callable[[Any], bool]) -> Iterable[Any]:
temp = int(input())
while(predicate(temp)):
yield temp
def main():
sequence = list(ReadSeqIntWhile(lambda p: p != 0))
print(f"numbers count: {len(sequence)}, average value: {statistics.mean(sequence)}")
if __name__ == "__main__":
main()
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
N = int(input())
s = 0
k = 0
sr = 0
while N != 0:
s += N
k += 1
N = int(input())
sr = s/k
print('Количество введённых чисел - ',k)
print('Среднее арифметическое введённых чисел = ',sr)
Ответ:
//Python 3.8.3
from typing import Callable, Any, Iterable
import statistics
def ReadSeqIntWhile(predicate: Callable[[Any], bool]) -> Iterable[Any]:
temp = int(input())
while(predicate(temp)):
yield temp
temp = int(input())
def main():
sequence = list(ReadSeqIntWhile(lambda p: p != 0))
print(f"numbers count: {len(sequence)}, average value: {statistics.mean(sequence)}")
if __name__ == "__main__":
main()