Please help me put this in order!! THANKYOU!!
(CO 4 and 6) Create a program with a function named flipCoin that will flip a coin as many times as the user asks. The flipCoin function should return “heads” or “tails”. The program should continue while the user presses Y.
SAMPLE OUTPUT:
|
How many times do you want to flip a coin? 5 You got: tails You got: tails You got: tails You got: tails You got: heads To continue press Y: Y How many times do you want to flip a coin? 3 You got: heads You got: tails You got: tails To continue press Y: N |
![flips = int(input(How many times do you want to flip a coin?)) if(flip== 1); [Choose cont=Y while cont==Y: [Choose] [Ch](http://img.homeworklib.com/questions/f5408410-8ace-11ec-a271-53e0e335c112.png?x-oss-process=image/resize,w_560)
The required sequence of statements is given below. Thumbs Up please if it helps. :)
1)import random
2)#flip coin function returns a heads or tails depending on what is
flipped
3)def flipCoin():
4) flip = random.randint(1,2);
5) if(flip == 1):
6) return "heads"
7) else:
8) return "tails"
9)def main():
10) cont = "Y"
11) while(cont == "Y"):
12) flips = int(input("How many times do you want to flip a coin?
"))
13) for i in range(0,flips):
14) print("You got",flipCoin())
15) cont = input("To continue press Y : ").upper()
16)if __name__ == '__main__':
17) main()
SEE SCREENSHOT LINE NUMBER TELLS SEQUENCE

Run Debug Stop e Share A Save Beautify Language Python 3 @ main.py 1 import random 2 #flip coin function returns a heads or tails depening on what is flipped 3- def flipCoin(): flip = random.randint(1,2); if(flip == 1): return "heads" else: return "tails" 9 def main(): cont = "/" while(cont == "Y"): flips = int(input("How many times do you want to flip a coin? ")) for i in range(@,flips): print("You got",flipCoin()) cont = input("To continue press Y: ").upper() 16 if _name__ == '_main__': 17 main() 13 - 15 input How many times do you want to flip a coin? 5 You got tails You got tails You got tails You got heads You got tails To continue press Y: Y How many times do you want to flip a coin? 3 You got heads You got tails You got tails To continue press Y : N ... Program finished with exit code o Press ENTER to exit console.
Please help me put this in order!! THANKYOU!! (CO 4 and 6) Create a program with...
(CO 4 and 6) Create a program with a function named rollDice that will roll a dice as many times as the user asks and with a user specified number of sides. The function should return the roll of the die. The program should continue while the user presses Y. Sample output: How many times do you want to roll the die? 5 How many sides does the die have: 6 You rolled 1 You rolled 2 You rolled...
Write a function that flips a coin; it returns heads or tails. Use that function to write a GetHeadsInARow functions that accepts the number of heads to roll in a row before you return with total rolls it took to get that number of heads in a row. Please Code in Python3 my attempt below will not print out the answer and I do not know why def HeadTails(): from random import randrange """Will simulate the flip of a coin."""...
In C++ please Create a coin-flipping game. Ask the user how many times to flip the coin, and use the random function to determine heads or tails each time a coin is flipped. Assume the user starts with $50. Every time the coin is flipped calculate the total (heads +$10, tails -$10). Create another function to test if the user has gone broke yet (THIS FUNCTION MUST RETURN A BOOLEAN TRUE/FALSE VALUE). End the program when the user is broke...
Write a C program that prompts the user for the number for times the user wants to flip a coin. Your program will flip a virtual coin that number of times and return the following: 1) The number of times heads occurred. 2) The number of times tails occured. Then take the coin flip program and modify the random number generator to roll a single 6-sided dice. DO NOT DISPLAY THE RESULTS OF EACH ROLL. 1) Ask the user how...
Practice: • function • loops • if condition • random Roll a dice many times, you will see that each face value will count of roughly 1/6 • write a function • roll a dice once, return value will be 1-6, • use your functin I call your function 6000 times • count how many times of face 1 • count how many times of face 2 • print out the numbers of total face 1, 2, ..., 6 you...
Write a program that simulates the toss of a coin. Whenever a coin is tossed the result will be either a head or tail. Prompt the user as shown by entering an ‘H’ for heads or ‘T’ for tails. Use a loop for input validation of an ‘h’ or ‘t’. Make sure that both an upper case and lower case will be accepted. Have the computer generate a random number. Assign a char variable a (‘h’ ^ ’t’) head or...
(Microsoft Visual Source, C++, Course: CIS-5, Intro to
Programming)
Write a program that starts a player off with a bank of
$15.00. A coin will flip and randomly choose heads or tails.The
user will guess heads or tails to win. If the coin flip matches the
player's guess his bet will be doubled. It costs 1 dollar to play
and the program will bet that amount automatically each time as
long as there is the available bank amount.
Note: Do...
Using c++ Write a function named coinToss that simulates tossing
a coin. When you call the function it should generate and return a
random number in the range 1 through 2. 1 represents heads and
2 represents tails.
Exercise 1 (40 points) Write a function named coinToss that simulates tossing a coin. When you call the function it should generate and return a random number in the range 1 through 2.1 represents heads and 2 represents tails Use the function...
Higher or Lower Game(use python3 to solve this) You will build a game that asks the user to guess a random number between 1-100. Your program will do the following: Ensure user input is valid (users can only guess integers) Provide a hint for each valid guess: the answer is either going to be higher or lower than the guess Solution import random # Define a function that asks the user for input and DOESN'T QUIT until the user...
The Coin Tossing simulation Coin.java The Coin class must be the enum class, defining the instances HEADS and TAILS. CoinTossing.java The CoinTossing class should be a simple class (with a main method) that uses the values provided by a Coin class, and performs a simulation of the tossing of a coin. There must be a separate (possibly static) flip method that takes no arguments and returns a value of the Coin class. The result returned from the flip method is...