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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started