Python Programming: An Introduction to Computer Science
3rd Edition
ISBN: 9781590282779
Author: John Zelle
Publisher: Franklin Beedle & Associates
expand_more
expand_more
format_list_bulleted
Question
Chapter 9, Problem 10PE
Program Plan Intro
Estimate the Pi value
Program plan:
- Import the header file.
- Define the main method.
- Read the iteration value from the user
- Call the “simDarts” method
- Call the “getPi” method
- Call the “printSummary” method
- Define the “simDarts” methods
- Set the window size
- Set the coords
- Set the value
- Iterate “i” until it reaches “n” value
- Call the “getDarts” method
- Check the condition
- Increment the “hits” value
- Otherwise, set the value
-
- Close the window
- Return the value
-
- Define the “getDarts” method
- Get the “x” and “y” values
- Check the calculate of value is less than or equal to 1
- Return true
-
- Otherwise, return false
-
- Return true
- Define “getPi” method
- Calculate the “pi” value
- Return “pi” value
- Define “printSummary” method
- Display the output
- Call the function “main()”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
A coin is flipped 8 times in a row (assume all outcomes are equally likely).
For each of the following questions, you should write your answer as an expression. Do not give the
final numeric value. For example, you should write C(4,2)/24 instead of 0.375.
Q1.1 What is the probability that it lands on heads exactly four times?
There are two isotopes of an unknown
element, X-19 and X-21. The
abundance of X-19 is 14.29%.
A weighted average uses the
percentages of each isotope to scale
their contribution to the total mass.
Each isotope's contribution is the
percentage (in decimal form)
multiplied by the mass of the isotope.
What is the contribution (in amu) to
the weighted average from the X-19
isotope, which has a mass of 19.00
amu?
Use the Crosswind Method 1 - with sin to solve the questions below.
You are advised by the tower for landing, 350/16 on runway 3.
1. What is the angle you are going to use?
2.
What is the crosswind component of the wind speed in kn? Round the answer to nearest whole
number
Chapter 9 Solutions
Python Programming: An Introduction to Computer Science
Ch. 9 - Prob. 1TFCh. 9 - Prob. 2TFCh. 9 - Prob. 3TFCh. 9 - Prob. 4TFCh. 9 - Prob. 5TFCh. 9 - Prob. 6TFCh. 9 - Prob. 7TFCh. 9 - Prob. 8TFCh. 9 - Prob. 9TFCh. 9 - Prob. 10TF
Ch. 9 - Prob. 1MCCh. 9 - Prob. 2MCCh. 9 - Prob. 3MCCh. 9 - Prob. 4MCCh. 9 - Prob. 5MCCh. 9 - Prob. 6MCCh. 9 - Prob. 7MCCh. 9 - Prob. 8MCCh. 9 - Prob. 9MCCh. 9 - Prob. 10MCCh. 9 - Prob. 2DCh. 9 - Prob. 3DCh. 9 - Prob. 1PECh. 9 - Prob. 2PECh. 9 - Prob. 3PECh. 9 - Prob. 4PECh. 9 - Prob. 5PECh. 9 - Prob. 6PECh. 9 - Prob. 7PECh. 9 - Prob. 8PECh. 9 - Prob. 9PECh. 9 - Prob. 10PECh. 9 - Prob. 11PECh. 9 - Prob. 12PECh. 9 - Prob. 13PECh. 9 - Prob. 14PE
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Imagine there are N teams competing in a tournament, and that each team plays each of the other teams once. If a tournament were to take place, it should be demonstrated (using an example) that every team would lose to at least one other team in the tournament.arrow_forwardThe density of an object is 2 g/cm3. To convert this to kg/m3, we need to divide it by 1000 to change grams to kilograms. Then, we need to multiply it by 10 to the power of what number to change cm3 to m3.arrow_forwardThe size of a colony of blue bacteria growing in a petri dish is modeled by the equation where t is time in days. The size of a colony of green bacteria is modeled by the equation where t is again time in days. Both colony sizes are measured in square centimeters. Part A: Graph the growth of both colonies on the same plot over the course of 6 days in one hour increments. One way to get one hour increments is to use a step size of 1/24. Another way is to use linspace and specify that it should create 6days x 24hours evenly spaced values. In either case, make sure you start at 0 days, not 1 day. Make the color of the curve match the color of the bacteria it represents. Give your graph a title and axis labels. Part B: How large is the green bacteria colony when the blue colony reaches its maximum size. You must answer this question using Matlab calculations, not manually entering the answer. To check your work, the blue colony’s maximum size is 270.56 and when it reaches that…arrow_forward
- In a candy store, there are N different types of candies available and the prices of all the N different types of candies are provided to you. You are now provided with an attractive offer. You can buy a single candy from the store and get at most K other candies ( all are different types ) for free. Now you have to answer two questions. Firstly, you have to find what is the minimum amount of money you have to spend to buy all the N different candies. Secondly, you have to find what is the maximum amount of money you have to spend to buy all the N different candies. In both the cases you must utilize the offer i.e. you buy one candy and get K other candies for free. Example 1: Input: N = 4 K = 2 %3D candies[] = {3 2 1 4} Output: 3 7arrow_forwardA standard science experiment is to drop a ball and see how high it bounces. Once the “bounciness” of the ball has been determined, the ratio gives a bounciness index. For example, if a ball dropped from a height of 10 feet bounces 6 feet high, the index is 0.6, and the total distance traveled by the ball is 16 feet after one bounce. If the ball were to continue bouncing, the distance after two bounces would be 10 ft + 6 ft +6 ft + 3.6 ft = 25.6 ft. Note that the distance traveled for each successive bounce is the distance to the floor plus 0.6 of that distance as the ball comes back up. Write a program that lets the user enter the initial height from which the ball is dropped, the bounciness index, and the number of times the ball is allowed to continue bouncing. Output should be the total distance traveled by the ball. Below is an example of the program input and output: Enter the height from which the ball is dropped: 25 Enter the bounciness index of the ball: .5 Enter the number of…arrow_forwardThere are 7 balls hidden in a box (3 blue and 4 green). If you first select a green ball and do not replace in the box, what is the probability that the second ball you select from the box will also be green? [Your answer can be written either as a fraction or decimal]arrow_forward
- The average of a step function computed with the definite integral matches the average computed in the usual way. Test this in the following situations by finding the average of the values directly, and then as the integral of a step function. Suppose a math class has four equally weighted tests. A student gets 60 on the first test, 70 on the second, 80 on the third, and 90 on the last.arrow_forwardCorrect answer will be upvoted else Multiple Downvoted. Computer science. You are given a positive number x. Observe the littlest positive integer number that has the amount of digits equivalent to x and all digits are unmistakable (extraordinary). Input The principal line contains a solitary positive integer t (1≤t≤50) — the number of experiments in the test. Then, at that point, t experiments follow. Each experiment comprises of a solitary integer number x (1≤x≤50). Output Output t replies to the experiments: on the off chance that a positive integer number with the amount of digits equivalent to x and all digits are diverse exists, print the littlest such number; in any case print - 1.arrow_forwardQ10: Using (ode45, ode23, or ode15s), solve the below dynamic electrical system differential equation. 1. The charge Q(t) on the capacitor in the electrical circuit shown satisfies the differential equation where d²Q dQ 1 +R- + √ √e dt2 dt L = 0.5 R = 6.0 C= 0.02 and V(t) is the applied voltage. V(t) = V(t), henrys is the coil's inductance ohms is the resistor's resistance farads is the capacitor's capacitance ellee (i) Is the circuit oscillatory? (ii) If V(t) = 24 sin(10r) volts and Q(0) = 0 = Q'(0), find Q(t). (iii) Sketch the transient solution, the steady state solution, and the full solution Q(t).arrow_forward
- Print the distance covered by each car after each hour. After 10 hours, the car with highest distance covered shall win. You shall print the car model that won the race e.g. "BMW i8 Won the race". As you know, distance (km) = time (hrs) X speed (km/hr). So, you understand, the maximum distance a car can travel in 10 hours, based on above rules is 5000 km, how? say each time maximum number was generated for the race (10 X 500). To calculate total distance traveled by each car, add another attribute, odoMeter in AutomaticCar and initialize it to 0. After each hour, add the total distance traveled by the car in that round in odoMeter field.arrow_forwardSuppose you're flipping a coin 30 times. What R code would give the the probability of flipping: exactly 25 heads at most 16 heads strictly more than 10 headsarrow_forwardProblem 1. You are playing a version of the roulette game, where the pockets are from 0 to 10and even numbers are red and odd numbers are black (0 is green). You spin 3 times and add up the values you see. What is the probability th at you get a total of 17 given on the first spin you spin a 2? What about a 3? Solve by simulation and analytically.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY