Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts International Edition

Authors: David M. Kroenke

6th Edition International Edition

0133098222, 978-0133098228

More Books

Students also viewed these Databases questions

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago