Issue
from math import sin, cos
def Sling():
b_h = float(input("Input starting speed: "))
b_angl = float(input("Input starting angle: "))
vy = b_h * sin(b_angl)
vx = b_h * cos(b_angl)
g = 9.8
t = (vy/8)
Max_height = (vy - (-g*t*t)) # max height of the throw
tx = 0
Projectile_CS = (vy * tx) - (-g*tx*tx) # current spot of the projectile
while Projectile_CS >= 0:
tx += 0.1
else:
print("Done")
Max_distance = tx * vx
print("Max")
for x in range(round(float(Max_height)/5)):
print("*")
print("0", "_" * t, "_" * round((Max_distance)/5))
print("The maximum height is: ", round(Max_height))
print("Max distance is: ", round(Max_distance))
return
Sling()
After the while Projectile_CS >= 0:
part of the code, it doesn't do anything, or looks like it. I can stop the code or restart with debugging but it doesn't help.
Solution
You never update Projectile_cs in the while loop, therefore you get stuck inside it
Your while loop continues until Projectile_speed value is < 0, but since you never change projectile_speed value in the while loop it will forever be < 0
For your code to work you have to update your variable in the while loop, according to what you did earlier it would probably look something like that
Projectile_CS = (vy * tx) - (-g*tx*tx)
while Projectile_CS >= 0:
tx += 0.1
Projectile_CS = (vy * tx) - (-g*tx*tx)
Answered By - Sparkling Marcel
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.