Created
October 28, 2016 08:59
-
-
Save anonymous/c209d4d30dd6614cd4f56fce7b37d47b to your computer and use it in GitHub Desktop.
null created by santirm97 - https://repl.it/EHb5/1
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
def main(): | |
print ("Lasketaan arvosanojen opintopistemaaralla painotettu keskiarvo.") | |
print ("Anna suoritustiedot muodossa") | |
print ("kurssikoodi,opintopistemaara,arvosana") | |
print ("Lopeta tietojen antaminen tyhjalla rivilla.") | |
lista = [] | |
rivi = input ("") | |
while rivi != "" : | |
lista.append (rivi) | |
rivi = input ("") | |
else: | |
if len(lista)<1: | |
print ("Ei suoritettuja kursseja.") | |
else: | |
opintopisteet = [] | |
arvosana = [] | |
summa = [] | |
for luku in lista: | |
kurssi = luku.split (",") | |
opintopisteet.append (float (kurssi[1])) | |
arvosana.append (float (kurssi[2])) | |
for i in range(len(arvosana)): | |
summa.append (opintopisteet[i] * arvosana[i]) | |
arvosana_summa = 0.0 | |
summa_summa = 0.0 | |
for arvo in arvosana: | |
arvosana_summa += arvo | |
for luku in summa: | |
summa_summa += luku | |
keskiarvo = summa_summa / arvosana_summa | |
print ("Arvosanojen painotettu keskiarvo on {:.2f}.".format(keskiarvo)) | |
main () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment