Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

hi, can you help me figure out what's wrong with my code and how to fix it. I think its something with the loop function

image text in transcribedimage text in transcribedimage text in transcribedhi, can you help me figure out what's wrong with my code and how to fix it. I think its something with the loop function Here is what it should do: If the player does not come close enough the target after 5 tries, they lose. If they get close enough to the target, they win. Use decision logic to decide if they win during a try, and if they do, use a return statement to end the function (and thus end the loop).

from a04_artillery_games import calculate_projectile_distance from a04_artillery_games import calculate_launch_angle import random import math def raging_rabbits2(): it will be an interactive program that takes input from the keyboard calculates some values, and prints output to the console." #print outcome print("Welcome to Raging Rabbits!") initial_velocity = random.randint(100, 200) print("Your cannon has been calibrated with an initial launch velocity of", initial velocity, "meters/second."), min_distance = calculate_projectile_distance (10, initial velocity) max_distance = calculate_projectile_distance (45, initial_velocity) print("At this velocity, you can hit a target between %.2f" % min_distance, "and %.2f" % max_distance, "meters."), range = max_distance - min_distance error_allowed = 0.65 * range print("To succeed, you must land your bomb within %0.2f" % error_allowed, "meters of the target."), target_distance = random. randint(int(min_distance), int(max_distance)), print("Your target is located at", target_distance, "meters."), print("You get 5 tries to hit your target.") print() 09 print("Your target is located at", target_distance, "meters."), print("You get 5 tries to hit your target."); print() for i in range(1,6): print("Attempt", i) print() launch_angle = int(input("Enter your launch angle in (degrees): ")) distance = calculate_projectile_distance (launch_angle, initial_velocity), print("Your projectile traveled", distance, "meters.") error = target_distance - distance print("Your shot was", error, "meters from the target."); print() if (int(error) -(int(error_allowed) )): print("Your hit your target!") return print("Your were not close enough to the target. :) 56 57 58 #our main program here: if __name__ == '_main_': raging_rabbits2() You get 5 tries to hit your target. Traceback (most recent call last): File "/Users/marissakachadoorian/Desktop/CS108/a06_raging_rabbits2.py", line 58, in raging_rabbits2(). File "/Users/marissakachadoorian/Desktop/CS108/a06_raging_rabbits2.py", line 37, in raging_rabbits2 for i in range(6): TypeError: 'float' object is not callable dhcp-wifi-8021x-168122206209:CS108 marissakachadoorian$ 11

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

More Books

Students also viewed these Databases questions

Question

1 What are the dimensions used in Hofstedes model of culture?

Answered: 1 week ago