0

how to make sure that the output is only one row for example output is only print(a)

hea_hind= 5.0 a= "Väga hea!" b= "Hea!" c= "Rahuldav" d= "Mitte rahuldav" e= "Loll" h1 = int(input("Matemaatika 1.kursuse hind: ")) h2 = int(input("Matemaatika 2.kursuse hind: ")) h3 = int(input("Matemaatika 3.kursuse hind: ")) h4 = int(input("Matemaatika 4.kursuse hind: ")) h5 = int(input("Matemaatika 5.kursuse hind: ")) keskmine= float (h1 + h2 + h3 + h4 + h5)/5 print("Keskmine hind on ", keskmine) if keskmine>= hea_hind: print(a) if keskmine>= hea_hind-1.0 != hea_hind: print(b) if keskmine>= hea_hind-2.0 != hea_hind-1.0: print(c) if keskmine>= hea_hind-3.0 != hea_hind-2.0: print(d) if keskmine>= hea_hind-4.0 != hea_hind-3.0: print(e) print ("Tõenäoliselt õpetaja paneb sulle", round(keskmine))

16th Sep 2016, 5:50 PM
Tjomq Jazz
Tjomq Jazz - avatar
1 Odpowiedź
0
To answer your question, use elif statements. if keskmine>= hea_hind: print (a) elif keskmine>= hea_hind-1 != hea_hind: print (b) etc. On another note, you dont need to float this: keskmine= float (h1 + h2 + h3 + h4 + h5)/5 the division will make it a float by default, so this should work fine too: keskmine= (h1 + h2 + h3 + h4 + h5)/5 note, keep the () around the h1 + etc. so that they get added together before they get divided by 5.
16th Sep 2016, 8:01 PM
Luke Armstrong