Last active
December 24, 2015 04:19
-
-
Save DOOMer/6743149 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
# список для сохзранения введенных данных | |
input_list = [] | |
n = 0 # сюда будем вводить числа | |
while not n < 0: # пока n не отрицательно | |
# просим пользователя ввести число | |
n = float(input("Enter the num: ")) | |
# и добавляем это число в список | |
input_list.append(n) | |
# при вводе отрицательного числа происходит выход из цикла white | |
# и вычисление среднего арифметического введенных чисел | |
# (исключая последнее, отрицательное) | |
print(sum(input_list[:-1])/(len(input_list)-1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment