Answered step by step
Verified Expert Solution
Question
1 Approved Answer
import math GRAVITY = 3 2 . 1 5 2 2 print ( Welcome to the Angry Birds aimbot! Go pig or go home!
import math
GRAVITY
printWelcome to the Angry Birds aimbot! Go pig or go home!"
# STEP
printWhat is the bird's initial velocity?"
# Get the bird's initial velocity as input
initvelocity floatinput
printWhat is the bird's launch angle in degrees?"
# Get the bird's launch angle as input
launchangledegrees floatinput
# Convert launch angle from degrees to radians
launchangleradians math.radianslaunchangledegrees
printWhat is the height of the slingshot in feet?"
# Get the height of the slingshot as input
slingshotheight floatinput
CALCULATE the duration of the flight in seconds
find the time it takes for the bird to hit the ground by
multiplying times the initial velocity times the sin of the launch angle in radians.
Divide all of that by GRAVITY and store it into a value called time
time initvelocity math.sinlaunchangleradians GRAVITY
CALCULATE the maximum horizontal distance
by multiplying the initial velocity by the cosine of the launch angle in radians by the time calculated from the previous step
Store it into a variable called distance
distance initvelocity math.coslaunchangleradians time
# Calculate the maximum height
maxheight slingshotheight initvelocity math.sinlaunchangleradians GRAVITY
# PRINT the outputs of the code using these print statements fill in the blanks truncated to two decimal places:
printfDuration of flight: time:f seconds"
printfBirds maximum horizontal distance: distance:f feet"
printfMax height of the bird: maxheight:f feet"
# STEP
printEnter the xcoordinate of the pig:"
# GET the pig's xcoordinate as input
x floatinput
printEnter the ycoordinate of the pig:"
# GET the pig's ycoordinate as input
y floatinput
# CALCULATE the straightline distance from the bird & slingshot to the pig
# Use the distance formula with the points xcoordinate of the pig, ycoordinate of the pig and slingshot height
straightlinedistance math.sqrtxy slingshotheight
# PRINT the results. Replace X with the calculated numbers. Truncate the output to two decimal places:
printfStraightline distance to the pig:straightlinedistance:f feet"
# This is the time when the bird is directly over the pig x y
timepig xinitvelocity math.coslaunchangleradians
# This is the yposition of the bird at the time it is directly over pig
ypig slingshotheight initvelocity math.sinlaunchangleradians timepig GRAVITY timepig
ypigdistabove ypig y
# PRINT the results. Fill in the blanks with the calculated numbers. Truncate the output to two decimal places etc.
printfThe bird will be over the pig at time timepig:f seconds. The bird will be ypigdistabove:f feet above the pig."
# STEP
printEnter the time in seconds to calculate the bird's position:"
# GET the time as input
t floatinput
# These are the x and y coordinates of the bird at the inputted time
xatinputtedtime initvelocity math.coslaunchangleradians time
yatinputtedtime slingshotheight initvelocity math.sinlaunchangleradians time GRAVITY time
# PRINT the time that was provided by the user and the coordinates of the pig at that time
# DO NOT TRUNCATE the value of the inputted time, but TRUNCATE the x and y coordinates at that time using decimal places
printfCoordinates of bird at t seconds: xatinputtedtime:fyatinputtedtime:f
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