Write a programBasic10 XPExercise 7/15

Sum of even numbers

Task

The program generates 15 random whole numbers from ⟨0; 50⟩ and prints the sum of the even ones.

Split it into functions the tests call directly:

  • vygeneruj() returns a list of 15 random whole numbers from 0 to 50,
  • sucet_parnych(zoznam) returns the sum of the even numbers in the list.

Examples

  • Call

    print(sucet_parnych([1, 2, 3, 4]))

    Expected output

    6
  • Call

    z = vygeneruj()
    print(len(z) == 15, all(type(x) == int and 0 <= x <= 50 for x in z))
    print(len({tuple(vygeneruj()) for _ in range(20)}) > 1)

    Expected output

    True True
    True

After you submit, 4 hidden tests will also check your solution: no even number, zeros, an empty list, larger numbers.

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.