@valoro/

media_ponderada_1

Python

http://altocodigo.blogspot.com/2018/07/media-ponderada.html

fork
loading
Files
  • main.py

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.7754607225218095","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"I05vdGFzIGRlIGxvcyBleMOhbWVuZXMKeD1bNyw0LDksMyw2LDEwXQojUGVzb3MgZGUgY2FkYSBleGFtZW4uIFN1bWFuIDE9MTAwJQp3PVsuMSwuMDUsLjI1LC4wNiwuMDksLjQ1XQpwcmludCgnwr9Mb3MgcGVzb3Mgc3VtYW4gMT86JyxzdW0odyk9PTEuKQphcml0PTAKZm9yIGkgaW4geDoKICBhcml0Kz1pCmFyaXQvPWxlbih4KQpwcmludCgnTWVkaWEgYXJpdG3DqXRpY2E6Jyxhcml0KQpwb25kZXJhPTAKZm9yIGkgaW4gcmFuZ2UobGVuKHgpKToKICBwb25kZXJhKz14W2ldKndbaV0KcHJpbnQoJ01lZGlhIHBvbmRlcmFkYTonLHJvdW5kKHBvbmRlcmEsNikp"},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#Notas de los exámenes
x=[7,4,9,3,6,10]
#Pesos de cada examen. Suman 1=100%
w=[.1,.05,.25,.06,.09,.45]
print('¿Los pesos suman 1?:',sum(w)==1.)
arit=0
for i in x:
  arit+=i
arit/=len(x)
print('Media aritmética:',arit)
pondera=0
for i in range(len(x)):
  pondera+=x[i]*w[i]
print('Media ponderada:',round(pondera,6))