ЗАДАЧА
Напишите программу, используя блок-схему (или Python, C++), которая вычисляет среднее значение оценок учащегося. Принимаемые баллы должны находиться в диапазоне от 0 до 100.
Пример консоли:
Введите результаты тестов от 0 до 100.
Чтобы завершить программу, введите -1.
Код: Выделить всё
Enter score: 90
Enter score: 80
Enter score: 150
Score must be from 0 to 100. Try again.
Enter score: 75
Enter score: -1
Score count: 3
Score total: 245
Average score: 81.6667
Код: Выделить всё
print("Enter score: ")
score = int(input())
scoreCount = 3
while score >= 0 and score 100:
print("Score must be from 0 to 100. Try again.")
score = int(input())
else:
if score < 0:
print("Score count: ", end='', flush=True)
print(scoreCount)
print("Score total: ", end='', flush=True)
print(scoreTotal)
print("Average: ", end='', flush=True)
print(avgScore, end='', flush=True)
else:
scoreTotal = score + score + score
avgScore = float(scoreTotal) / scoreCount
Я ожидаю при вводе этого:
Код: Выделить всё
Enter test scores from 0 to 100.
To end the program, enter -1.
START
Enter score: 90
Enter score: 80
Enter score: 150
Score must be from 0 to 100. Try again.
Enter score: 75
Enter score: -1
Score count: 3
Score total: 245
Average score: 81.6667
END
Подробнее здесь: https://stackoverflow.com/questions/742 ... he-average
Мобильная версия