Answered step by step
Verified Expert Solution
Question
1 Approved Answer
for python CS104 - Fall 2021 Final - Page 6 of 7 5. (15 points) Write a Python program that simulates flipping a coin. The
for python
CS104 - Fall 2021 Final - Page 6 of 7 5. (15 points) Write a Python program that simulates flipping a coin. The program should have a method called four Tails() that repeatedly flips a coin until the results of the coin toss are four tails in a row. You may use a randint() method from random module to ensure both head and tail have the same probability to appear (if you generate two random numbers, you may consider one to be as tail and another one to be as head). Each time the coin is flipped, program should print out H for heads, or T for tails. When four tails in a row are flipped, the program should terminate. Here is a possible output of the program: TTHTTHHTHTHTTTT Four tails in a row 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