# 1
L = []
while True:
x = int(input('Enter a score (-1 to exit): '))
if x == -1:
break
L.append(x)
# 2
print('You have entered:')
for x in L:
print(x, end=' ')
# 3
L.sort()
print('You have entered:')
for x in L:
print(x, end=' ')
# 5
avr = sum(L) / len(L)
print(f'Average score is {avr:.2f}')
# 6
n = len(L)
if n == 0:
median = None
elif n%2 == 1:
median = L[n//2+1]
else:
median = (L[n//2-1] + L[n//2])/2
print(f'Median score if {median}')
# 7
range = L[-1] - L[0]
print(f'The range of scores is {range}')
# 8
L = L[1:-1]
print('Minimum and maximum values are removed')
# 10
avr = sum(L) / len(L)
print(f'Average score is {avr:.2f}')
# 11
n = len(L)
if n == 0:
median = None
elif n%2 == 1:
median = L[n//2+1]
else:
median = (L[n//2-1] + L[n//2])/2
print(f'Median score if {median}')
# 12
range = L[-1] - L[0]
print(f'The range of scores is {range}')
Comments
Leave a comment