Question: in python, Write a function named coinFlip that accepts an input file name as a parameter, and returns a list of tuples. The input file
in python,
Write a function named coinFlip that accepts an input file name as a parameter, and returns a list of tuples. The input file represents the results of sets of coin flips that are either heads (H) or tails (T) in either upper or lower case, separated by at least one space. Your function should consider each line to be a separate set of coin flips and should output a separate tuple for each line. The tuple should contain the number of heads and the percentage of heads in that line, rounded to the nearest tenth. If this percentage is more than 50%, you should include a "You win" message.
input:
H T H H T
T t t T h H
h
output:
[(3, '60.0%', 'You win!'), (2, '33.3%'), (1, '100.0%', 'You win!')]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
