0
Dubt converting str to float - Why the result is returning as a float if i didnt made the conversion of str to float?
note = int(input("Insert note 1")) note2 = int(input("Insert note 2")) note3 = int(input("Insert note 3")) note4 = int(input("Insert note 4")) average = (note + note2 + note3 + note4) / 4 print ("The notes average is:", average) input ("Press ENTER to exit")
6 Respostas
+ 5
You use a float division symbol - "/"
It automatically converts int to float. If you want to have an integer division, you should use the "//" symbol, a floor division (rounds down to the next smallest integer).
+ 4
André Costa Depends on you, actually. You can keep it a float, so it's closer to the actual mathematical truth, but you can display it "pretty" with adequate string formatting :)
+ 3
Kuba Siekierzyński average = int((note1+note2+note3+note4)/4)
+ 2
張皓雨 Indeed.
+ 1
Many Thanks guys =) awasome comunity
0
Kuba Siekierzyński but to make the program prettier and more correct should we place float instead of int right? thanks =)