Question
controlling a cannon which is trying to hit an target some distance d away. You're permitted to pick the speed of the projectile, and the
controlling a cannon which is trying to hit an target some distance d away. You're permitted to pick the speed of the projectile, and the angle at which the cannon is shot. In the event that you miss your target (outside of some tolerance), the game tells you in the event that you shot short of or past the target and allows you to attempt once more. with six incomplete functions and the framework expected to play the game. For this game, you're required to finish these six functions. description of this function is given below.
assume that perfect physics is involved no wind, constant gravity. d =v2 sin(2)/g
assume that equals pythons built in value for , math.pi. (gravity) g= 9.81
1. valid velocity is a string with a positive number, with a decimal point. For example the following are valid velocities: 20, 12.14, 80., while these are not valid velocities: 20m/s, -19, 11.2.6.
2. valid angle is a string with a number, or with a decimal point where the last character of the string is either a d or D saying that the given angle is in degrees or a r or R given angle is in radians. if in degrees the numeric portion of the string must be less than 90 and greater than 0, and if in radians the numeric portion of the string must be less than /2 and greater than 0. For example, 23d, 1.5R, and 77.D are valid angles, while -23d, 3.14r, and 7.7R are not valid angles.
Function Name | Description |
get distance(float, float) -> float | The first parameter is the velocity, the second parameter is the angle of fire. Returns the horizontal distance traveled by the projectile as given by equation |
degrees to radians(float) -> float | Given some number of degrees, it returns the corresponding converted amount of radians. |
get radian of(str) -> float | Given a valid angle, it takes the numerical value of the string and returns that angle in radians. |
is a number(str) -> bool | Given a string, returns True if and only if that string represents a positive number (potentially with a decimal). |
is valid angle(str) -> bool | Given a string, returns True if that string is of the form described earlier in this document. |
approx equal(float, float, float) -> bool | Returns True if and only if the first two parameters are within some value of each other, where said value equals the third parameter. |
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