Write a program that simulates coin tossing. Let the program prompt the user to enter the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a program that simulates coin tossing. Let the program prompt the user to enter the number of tosses N and count the number of times each side of the coin appears. Print the results. The program should call a separate function flip() that takes no arguments and returns 0 for tails and 1 for heads. The program should produce different results for each run. Sample Input/Output Enter the number of tosses N: 1000 The total number of Heads is: 495 The total number of Tails is: 505 Write a program that simulates coin tossing. Let the program prompt the user to enter the number of tosses N and count the number of times each side of the coin appears. Print the results. The program should call a separate function flip() that takes no arguments and returns 0 for tails and 1 for heads. The program should produce different results for each run. Sample Input/Output Enter the number of tosses N: 1000 The total number of Heads is: 495 The total number of Tails is: 505
Expert Answer:
Answer rating: 100% (QA)
import random def flip if randomrandom 05 return 0 else return 1 def main N in... View the full answer
Related Book For
Starting Out With Java From Control Structures Through Data Structures
ISBN: 9780133957051
6th Edition
Authors: Tony Gaddis
Posted Date:
Students also viewed these programming questions
-
ABC Pumps is a division of ABC Controls. The division manufactures and sells a pump in a variety of applications. During the coming year, it projects the following sales: 25,000 units $17 per unit...
-
Company Revenue for Fiscal Year 2014 (millions of dollars) Walmart 476,294 Exxon Mobil 407,666 Apple 170,910 General Motors 155,427 Ford Motor 146,917 General Electric 146231 Identify and explain...
-
Ivanhoe Company incurred research and development costs of $ 9 0 0 0 0 to develop a patent, and legal fees of $ 3 0 0 0 0 to register the patent. The patent has a legal life of 2 0 years and a useful...
-
An opera glass has an objective lens of focal length +3.60 cm and a negative eyepiece of focal length -1.20 cm. How far apart must the two lenses be for the viewer to see a distant object at 25.0 cm...
-
On June 30, 2013, Mission Corp. purchased $32,000 of inventory on a one-year, 5-percent note payable. Journalize the company's (a) Accrual of interest expense on December 31, 2013, (b) Payment of the...
-
(a) Provide an IUPAC name for each of the isomers that you drew in Exercise 2-16 (a). (b) For each isomer that you drew and named here, give all the free radical monochlorination and monobromination...
-
What is civil litigation and how does it differ from other types of litigation?
-
The following elements of stockholders equity are adapted from the balance sheet of Sandler Marketing, Corp. Sandler paid no preferred dividends in 2011. Requirement 1. Compute the dividends to the...
-
e. What is the expected total rate of return over the next year on a 3-year zero-coupon bond? (Do not round intermediate calculations. Round your answer to 1 decimal place.) Expected total rate of...
-
The primary purpose of the reformer is to convert methane and water to carbon monoxide and hydrogen (Equation 13.1). The extent of this reaction is limited by chemical equilibrium. where Subscript...
-
Discuss the concept of thread safety and the role of immutable data structures in multi-threaded applications. How can the use of immutable data help reduce synchronization overhead and prevent data...
-
The Wellington County OPP monitors accidents a the intersection of Highway 6 and County Road 7. Accidents numbers for the past 5 months have been 3, 2, 5, 1, and 4. Create the appropriate three-sigma...
-
A simple circuit has a 1 0 0 V battery, a 2 0 0 resistor, and a 1 . 0 F capacitor all connected in series. ( a ) What is the time constant for this circuit? ( b ) When the capacitor is full...
-
respond to the discussion In the IMA article, Activity-Based Costing (ABC) is explained as a cost allocation technique that traces indirect costs (often referred to as "overhead") to specific cost...
-
comments about these post? 1. The bullwhip effect is a word used to explain a situation in supply chain management where minor consumer demand changes can cause intense fluctuations in demand...
-
Prepare partial income statements for 2022 through gross profit, under each of the following cost flow assumptions. (Round answers to 2 decimal places, e.g. 125.25.) (1) Specific identification...
-
(a) State with reasons, whether the following statements are True or False: (i) A claim that an enterprise is pursuing through legal process, where the outcome is uncertain, is a Contingent...
-
1) Predict the organicproduct formed when BzCl reacts with cyclohexanol. BzCl = benzoylchloride. 2) Provide the majororganic product of the reaction below. 3) Draw the structureof the product formed...
-
True or False: When code in a method changes the value of a parameter, it also changes the value of the argument that was passed into the parameter.
-
What type of memory is usually volatile?
-
What is wrong with the following statement? char letter = "Z";
-
In a laboratory investigation, acetic acid is esterified in the liquid phase with ethanol at \(373.15 \mathrm{~K}\) and \(1 \mathrm{~atm}\) pressure to produce ethyl acetate and water according to...
-
The reaction for oxidation of sulphur is given by \[ \mathrm{SO}_{2}(\mathrm{~g})+\frac{1}{2} \mathrm{O}_{2}(\mathrm{~g}) ightarrow \mathrm{SO}_{3}(\mathrm{~g}) \] A mixture of sulphur dioxide and...
-
The following thermal decomposition occurs at \(400 \mathrm{~K}\) : \[ A(\mathrm{~s}) ightarrow B(\mathrm{~s})+C(\mathrm{~g}) \] The standard Gibbs free energy of the reaction, \(\Delta...
Study smarter with the SolutionInn App