Ejemplos calificaciones en python
Ejemplo calificaciones ciclo for
#pedir notas
#guardarlas en un arreglo
#recorrer ese arreglo y sumar notas, luego dividir y sacar el promedio
nota = 0
notas = []
x=1
print "si decsa salir pon un numero negativo"
while nota >= 0:
nota= float(raw_input("ingresar nota "+ str(x)+":"))
if nota >= 0:
notas.append(nota)
x = x +1
suma_notas=0
for i in range(len(notas)):
suma_notas = suma_notas + notas[i]
#print suma_notas
promedio = float(suma_notas) / len(notas)
print "tu promedio es: " +str(promedio)
Ejemplo 1 calificaciones con arreglos
arreglo = [1,2,5,7,8,4,9,10,10,10,10,10]
suma_calificaciones = 0
for i in range(len(arreglo)):
suma_calificaciones = suma_calificaciones + arreglo[i]
print suma_calificaciones
promedio = float(suma_calificaciones) / len(arreglo)
print promedio
Ejemplo 2 calificaciones con arreglos
#pedir notas
#guardarlas en un arreglo
#recorrer ese arreglo y sumar notas, luego dividir y sacar el promedio
nota = 0
notas = []
x=1
print "si decsa salir pon un numero negativo"
while nota >= 0:
nota= float(raw_input("ingresar nota "+ str(x)+":"))
if nota >= 0:
notas.append(nota)
x = x +1
suma_notas=0
for i in range(len(notas)):
suma_notas = suma_notas + notas[i]
#print suma_notas
promedio = float(suma_notas) / len(notas)
print "tu promedio es: " +str(promedio)
#pedir notas
#guardarlas en un arreglo
#recorrer ese arreglo y sumar notas, luego dividir y sacar el promedio
nota = 0
notas = []
x=1
print "si decsa salir pon un numero negativo"
while nota >= 0:
nota= float(raw_input("ingresar nota "+ str(x)+":"))
if nota >= 0:
notas.append(nota)
x = x +1
suma_notas=0
for i in range(len(notas)):
suma_notas = suma_notas + notas[i]
#print suma_notas
promedio = float(suma_notas) / len(notas)
print "tu promedio es: " +str(promedio)
Ejemplo 1 calificaciones con arreglos
arreglo = [1,2,5,7,8,4,9,10,10,10,10,10]
suma_calificaciones = 0
for i in range(len(arreglo)):
suma_calificaciones = suma_calificaciones + arreglo[i]
print suma_calificaciones
promedio = float(suma_calificaciones) / len(arreglo)
print promedio
Ejemplo 2 calificaciones con arreglos
#pedir notas
#guardarlas en un arreglo
#recorrer ese arreglo y sumar notas, luego dividir y sacar el promedio
nota = 0
notas = []
x=1
print "si decsa salir pon un numero negativo"
while nota >= 0:
nota= float(raw_input("ingresar nota "+ str(x)+":"))
if nota >= 0:
notas.append(nota)
x = x +1
suma_notas=0
for i in range(len(notas)):
suma_notas = suma_notas + notas[i]
#print suma_notas
promedio = float(suma_notas) / len(notas)
print "tu promedio es: " +str(promedio)
Comentarios
Publicar un comentario