Write a programBasic10 XPExercise 6/9

Coin toss

Task

The program asks how many coin tosses you want, "tosses" the coin that many times and prints whether heads or tails came up more often.

Split it into functions the tests call directly:

  • hod() returns orol (heads) or hlava (tails) at random,
  • vyhodnot(hody) gets a list of results and returns orol, hlava (whichever came up more often) or remiza (a tie).

Examples

  • Call

    print(vyhodnot(["orol", "hlava", "orol"]))

    Expected output

    orol
  • Call

    hody = [hod() for _ in range(300)]
    print(set(hody) == {"orol", "hlava"})

    Expected output

    True

After you submit, 3 hidden tests will also check your solution: a tie, no tosses, all tails.

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.