Question
What lead is safe in basketball? With our simple if-else construct, we can solve a remarkably interesting problem in the basketball game. Basketball is a
What lead is safe in basketball? With our simple if-else construct, we can solve a remarkably interesting problem in the basketball game. Basketball is a very fast-paced and high scoring game where game point leads can disappear quickly. As a spectator, it would be nice to able to figure out when a lead is insurmountable near the end of the game. It will be easy on our heart and keep blood pressure under control for spectators like me, who gets too excited watching the game. Sports writer Bill James has created an algorithm for determining just that. James's algorithm: Of course, the algorithm does not guarantee that a lead is safe - anything can happen, but as a sports analyst this is when he feels a game is safe. Following is the algorithm: Take the number of points one team is ahead Subtract 3 Add a half-point if the team that is ahead has the ball, and subtract a half-point if the other team has the ball. (Numbers less than zero become zero) Square the result If the result is greater than the number of seconds left in the game, the lead is safe So, here is your job. Create a flow chart (with Microsoft Visio) and arrange the following code in the correct order to produce the correct result. Comment your program heavily. Incorrect program: if has_ball_str == "Yes": lead_calculation_float = lead_calculation_float + 0.5 points_aead_int = int(points_str) seconds_remaining_int = int(input"Enter the number of seconds remaining: ")) lead_calculation_float = float(points_ahead_int - 3) has_ball_str = input"Does the lead team have the ball (Yes or No): ") if has_ball_str == "Yes": lead_calculation_float = lead_calculation_float + 0.5 has_ball_str = iput("Does the lead team have the ball (Yes or No): ") if lead_caculation_float > seconds_remaining_int: print("Lead is safe.") else: print("Lead is not safe.") point_str = input("Enter the lead in points: ") else: lead_calculation_float = lead_calculation_float - 0.2 lad_calculation_float = 0 if has_ball_str == 'Yes': lead_calculation_float = lead_calculation_float + 0.5 lead_calculation_float = lead_calculation_float ** 2 if lead_calculation_float What lead is safe in basketball? With our simple if-else construct, we can solve a remarkably interesting problem in the basketball game. Basketball is a very fast-paced and high scoring game where game point leads can disappear quickly. As a spectator, it would be nice to able to figure out when a lead is insurmountable near the end of the game. It will be easy on our heart and keep blood pressure under control for spectators like me, who gets too excited watching the game. Sports writer Bill James has created an algorithm for determining just that. James's algorithm: Of course, the algorithm does not guarantee that a lead is safe - anything can happen, but as a sports analyst this is when he feels a game is safe. Following is the algorithm: - Take the number of points one team is ahead - Subtract 3 - Add a half-point if the team that is ahead has the ball, and subtract a half-point if the other team has the ball. (Numbers less than zero become zero) - Square the result - If the result is greater than the number of seconds left in the game, the lead is safe So, here is your job. Create a flow chart (with Microsoft Visio) and arrange the following code in the correct order to produce the correct result. Comment your program heavily. Incorrect program: if has_ball_str == "Yes": lead_calculation_float = lead_calculation_float +0.5 points_aead_int = int(points_str) seconds_remaining int = int(input" Enter the number of seconds remaining: ")) lead_calculation_float = float ( points_ahead_int 3) has_ball_str = input"Does the lead team have the ball (Yes or No): ") if has_ball_str== "Yes": lead_calculation_float = lead_calculation_float +0.5 has_ball_str = iput("Does the lead team have the ball (Yes or No): ") if lead_caculation_float > seconds_remaining_int: print("Lead is safe.") else: print("Lead is not safe.") point_str = input("Enter the lead in points: ") else: lead_calculation_float = lead_calculation_float 0.2 lad_calculation_float =0 if has_ball_str = 'Yes': lead_calculation_float = lead_calculation_float +0.5 lead_calculation_float = lead_calculation_float 2 if lead_calculation_float
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