URI Online Judge | 1064
Positivos e Média
Adaptado por Neilor Tonin, URI
Brasil
Timelimit: 1
Leia 6 valores. Em seguida, mostre quantos destes valores digitados foram positivos. Na próxima linha, deve-se mostrar a média de todos os valores positivos digitados, com um dígito após o ponto decimal.
Entrada
A entrada contém 6 números que podem ser valores inteiros ou de ponto flutuante. Pelo menos um destes número será positivo.
Saída
O primeiro valor de saída é a quantidade de valores positivos. A próxima linha deve mostrar a média dos valores positivos digitados.
URI Online Judge | 1064
Positives and Average
Adapted by Neilor Tonin, URI
Brazil
Timelimit: 1
Read 6 values that can be floating point numbers. After, print how many of them were positive. In the next line, print the average of all positive values typed, with one digit after the decimal point.
Input
The input consist in 6 numbers that can be integer or floating point values. At least one number will be positive.
Output
The first output value is the amount of positive numbers. The next line should show the average of the positive values typed.
a = float(input())
b = float(input())
c = float(input())
d = float(input())
e = float(input())
f = float(input())
s=0
m =0
t =[a,b,c,d,e,f]
for n in t:
if n > 0:
s = s + 1
m = m + (n)
print('{} valores positivos'.format(s))
print('{:.1f}'.format(m/s))
Nenhum comentário:
Postar um comentário