Write a programExercise 3/4Elementary20 XP
Grade statistics in functions
Task
Split the program into three functions:
nacitaj_znamky(text)gets a string of grades separated by spaces (for example"1 3 2 1") and returns them as a list of whole numbers,priemer(znamky)returns the average grade rounded withroundto 2 decimal places,pocet_jednotiek(znamky)returns how many ones the list contains.
Under if __name__ == "__main__": the program reads a line of grades and prints:
Priemer: 1.75
Jednotky: 2
(for the input 1 3 2 1).
Examples
Input
1 3 2 1
Expected output
Priemer: 1.75 Jednotky: 2
Call
print(nacitaj_znamky("1 3 2 1"))Expected output
[1, 3, 2, 1]
After you submit, 5 hidden tests will also check your solution: the average, an average with a half, no ones, all ones, one grade.
Python starts the first time you run code.
Ctrl+Enter runs the program. Tab indents. Press Esc, then Tab, to leave the editor.
Input (stdin)
Each line = one call to input().
Output
Hints
Try it yourself first. Each hint reveals a little more - and lowers the reward a little.
Signed out, hints are free - but no XP is awarded either.
Solution
The solution unlocks after the last hint.