
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
![The outputs of the function DartNumbers consist of four numerical scalars (ex: a 1x1 numerical array):
yellow: A numerical scalar of the number of darts in the yellow region.
red: A numerical scalar of the number of darts in the red region.
blue: A numerical scalar of the number of darts in the blue region.
green: A numerical scalar of the number of darts in the green region.
Hint: For each point of throwX and throwY, calculate the radius r =
Vx² + y², which is the distance from the center (0,0) to the point (x,y).
Use this radius array and logical indexing to find the number of points in each region. The radii of the three circles on
dart board are 3,
5, and 10. Thus, if a point has distance 3.45, the point lies between circles of radius 3 and 5, which is the red region.
Restrictions: Do not use if statements or switch statements. Logical indexing should be used.
Ex:
For random values of inputs,
throwX
[ 6.2945
8.1158
-7.4603
8.2675
2.6472
-8.0492
-4.4300
0.9376
9.1501
9.2978]
throwY
[-6.8477
9.4119
9.1433
-0.2925
6.0056
-7.1623
-1.5648
8.3147
5.8441
9.1898]
From throwX, throwY, the first dart has x,y coordinates as (6.2945, -6.8477), and the 10th dart has x,y coordinates as (9.2978, 9.1898).
On calling
[yellow, red, blue, green] = DartNumbers(throwX,throwY)
%3D
The output is:
yellow
red = 1
blue
4
%3D
green
5
The output indicates that for given random arrays of throwX and throwY, out of total 10 darts thrown, 0 hit the board in the yellow region, 1
hits the board in the red region, 4 hit the board in the blue region, and 5 hit the board in the green region.](https://content.bartleby.com/qna-images/question/8de9ecd0-3cc9-475b-b184-ad0ee68f5a8e/32965b48-64a9-4b77-b89d-2652fd208b81/g0fg8zi_thumbnail.png)
Transcribed Image Text:The outputs of the function DartNumbers consist of four numerical scalars (ex: a 1x1 numerical array):
yellow: A numerical scalar of the number of darts in the yellow region.
red: A numerical scalar of the number of darts in the red region.
blue: A numerical scalar of the number of darts in the blue region.
green: A numerical scalar of the number of darts in the green region.
Hint: For each point of throwX and throwY, calculate the radius r =
Vx² + y², which is the distance from the center (0,0) to the point (x,y).
Use this radius array and logical indexing to find the number of points in each region. The radii of the three circles on
dart board are 3,
5, and 10. Thus, if a point has distance 3.45, the point lies between circles of radius 3 and 5, which is the red region.
Restrictions: Do not use if statements or switch statements. Logical indexing should be used.
Ex:
For random values of inputs,
throwX
[ 6.2945
8.1158
-7.4603
8.2675
2.6472
-8.0492
-4.4300
0.9376
9.1501
9.2978]
throwY
[-6.8477
9.4119
9.1433
-0.2925
6.0056
-7.1623
-1.5648
8.3147
5.8441
9.1898]
From throwX, throwY, the first dart has x,y coordinates as (6.2945, -6.8477), and the 10th dart has x,y coordinates as (9.2978, 9.1898).
On calling
[yellow, red, blue, green] = DartNumbers(throwX,throwY)
%3D
The output is:
yellow
red = 1
blue
4
%3D
green
5
The output indicates that for given random arrays of throwX and throwY, out of total 10 darts thrown, 0 hit the board in the yellow region, 1
hits the board in the red region, 4 hit the board in the blue region, and 5 hit the board in the green region.

Transcribed Image Text:Dart game: Dart location
Write a function called DartNumbers() that takes the location of darts thrown as an input, and finds the number of darts that hit the regions
yellow, red, blue, and green.
A 20x20 square dart board, as shown in the image below, consists of concentric circles with the center at (0,0). The radius of the yellow
circle is 3, the red circle is 5, and the blue circle is 10. A dart player throws 10 darts at the board randomly such that any place on the
board can be hit with an equal chance. The rand() function can be used to obtain a number with uniform distribution between -10 and 10.
Uniform distribution with a given interval means that an equal probability exists to get a number in that interval.
Dart Board
10
2.
-2
-10
-10
-2
4.
8.
10
The inputs of the function DartNumbers() are:
throwX: Indicates the x positions of the darts on the board. throwX is a 1x10 array of random numbers between -10 and 10 with a uniform
distribution using the rand function.
throw Y: Indicates the y positions of the darts on the board. throwY is a 1x10 array of random numbers between -10 and 10 with a uniform
distribution using the rand function.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps

Knowledge Booster
Similar questions
- check_game_over(): as the name suggests, this function should check to see if the game is over (if one side has no stones left in all of its pockets). It takes as an argument the game board and should return True if the game is over and False otherwise.arrow_forwardCustomized step counter Learning Objectives In this lab, you will Create a function to match the specifications Use floating-point value division Instructions A pedometer treats walking 2,000 steps as walking 1 mile. It assumes that one step is a bit over 18 inches (1 mile = 36630 inches, so the pedometers assume that one step should be 18.315 inches). Let's customize this calculation to account for the size of our stride. Write a program whose input is the number of steps and the length of the step in inches, and whose output is the miles walked. Output each floating-point value with two digits after the decimal point, which can be achieved as follows: print(f'{your_value:.2f}') Ex: If the input is: 5345 18.315 the output is: You walked 5345 steps which are about 2.67 miles. Your program must define and call the following function. The function should return the number of miles walked.def steps_to_miles(user_steps, step_length) # Define your function here if __name__…arrow_forwardmy_round(number, integer): Based on the built-in round(...) function. Takes an integer or float and returns a rounded float value that is the number rounded to the second argument's decimal place. First argument can be any float or integer. Second argument must be an integer. Examples: my_round(1234.5678, 2) and round(1234.5678, 2) should return 1234.57. my_round(1234.5678, -2) and round(1234.5678, -2) should return 1200.0.arrow_forward
- Create Array of Random Dates In this task you are required to write a function that will generate a column array (a variable called dates) containing N random dates. N is an integer (whole number) entered by the user and will indicate to the function how many random dates the user requires. The dates array will be structured as follows: • The array shall have two columns; column 1 will contain numbers indicating the day of each month (1-31) and column 2 will contain numbers indicating the month (Jan 1, Feb=2, Mar = 3.... Dec = 12). . Each day must be randomly generated (using the randi() function) taking into account the maximum number of days in each month (i.e. Jan, Mar, May, Jul, Aug. Oct and Dec have 31 days, Apr. Jun, Sep and Nov have 30 days and Feb will have 28 days). You must use an if-elseif-else statement to decide this. • We are assuming no leap years (e. February can only have days between 1-28). For example, the output from calling the function: output = dategen (3) could…arrow_forwardWeight Statistics Write a program that monitors monthly weight loss each of 12 months into an array of doubles. The program should calculate and display the total weight loss for the year, the average monthly weight loss, and the months with the highest and lowest amounts. Input Validation: Do not accept negative numbers for monthly weight loss.arrow_forwardOpengl Help Programming Language: c++ I need help setting coordinate boundries for this program so the shape can't leave the Opengl window. The shape needs to stay visiable.arrow_forward
- Alphabet Random Walk• Write a program to generate a random walk that spans a 10*10 character array (The initial values of the elements are all.). The program must randomly walk from one element to another, moving one element position up, down, left or right each time. The elements that have been visited are labeled with the letters A through Z in the order in which they were visitedarrow_forwardIn visual basic Declare a two-dimensional array that has 3 columns and 4 rows.arrow_forwardLearning Objectives: Python Programming Use loop over a stringReplace characters within a stringFunction (declaration and call)Write code in modular formInstructions Create a function only_chars that takes the line of text and returns the text line excluding the spaces, periods, exclamation points, or commas. Create a program that will read the input line, use the function, and then print the line, without spaces, periods, exclamation marks, or commas and their length. Ex: If the input is: Listen, Mr. Jones, calm down. the output is: ListenMrJonescalmdown21Do not forget if __name__ == "__main__" section!arrow_forward
- var adventurersName = ["George", " Tim", " Sarah", " Mike", " Edward"];var adventurersKilled = 3;var survivors;var leader = "Captain Thomas King";var numberOfAdventurers = adventurersName.length; survivors = numberOfAdventurers - adventurersKilled; console.log("Welcome to The God Among Us\n");console.log("A group of adventurers began their search for the mystical god said to live among us. In charge of the squad was " + leader + " who was famous for his past exploits. Along the way, the group of comrades were attacked by the god's loyal followers. The adventurers fought with bravado and strength under the tutelage of "+ leader + " the followers were defeated but they still suffered great losses. After a headcount of the remaining squad, "+ adventurersKilled +" were found to be dead which left only " + survivors + " remaining survivors.\n"); console.log("Current Statistics :\n");console.log("Total Adventurers = " + numberOfAdventurers);console.log("Total Killed = " +…arrow_forwardCoin Toss Write a function named coinToss that simulates the tossing of a coin. When you call the function, it should generate a random number in the range of 1 through 2. If the random number is 1, the function should display "heads". If the random number is 2, the function should display "tails". Demonstrate the function in a program that sks the user how many times the coin should be tossed and the coin then simulates the tossing of the coin that number of times.arrow_forwardpython programing: You are going to create a race class, and inside that class it has a list of entrants to the race. You are going to create the daily schedule of three or so races and populate the races with the jockey/horse entries and then print out the schedule. Create a race class that has The name of the race as a character string, ie “RACE 1” or “RACE 2”, The time of the race A list of entries for that race Create a list of of 3 (or 4) of those race objects(races) for the day For the list of entries for a particular race, make a entrant class (the building block of your entrants list) you should have The horse name The jockey name Now you need to Populate the structure (ie set up three races on the schedule, add 2-3 horses entries to each race. You can hardcode the entries if you want to, rather than getting them from the user, just to save the time of making a menu interface and whatnot. Be able to print the days schedule So example output would be…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON

Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education

Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY