Alright so I have beat my head over my desk for a few days over this one and I still cannot get it I keep getting this problem:
Traceback (most recent call last):
File "C:\Program Files (x86)\Wing IDE 101 4.1\src\debug\tserver\_sandbox.py", line 44, in <module>
File "C:\Program Files (x86)\Wing IDE 101 4.1\src\debug\tserver\_sandbox.py", line 35, in main
File "C:\Program Files (x86)\Wing IDE 101 4.1\src\debug\tserver\_sandbox.py", line 15, in __init__
builtins.TypeError: can't multiply sequence by non-int of type 'float'
over and over. I think I have hit the wall and really I have done a ecent amount of looking and testing but if anyone could point me in teh right direction it would be greatly appreciated.
from math import pi, sin, cos, radians
def getInputs():
a = input("Enter the launch angle (in degrees): ")
v = input("Enter the initial velocity (in meters/sec): ")
h = input("Enter the initial height (in meters): ")
t = input("Enter the time interval between position calculations: ")
return a,v,h,t
class Projectile:
def __init__(self, angle, velocity, height):
self.xpos = 0.0
self.ypos = height
theta = pi *(angle)/180
self.xvel = velocity * cos(theta)
self.yvel = velocity * sin(theta)
def update(self, time):
self.xpos = self.xpos + time * self.xvel
yvel1 = self.yvel - 9.8 * time
self.ypos = self.ypos + time * (self.yvel + yvel1) / 2.0
self.yvel = yvel1
def getY(self):
"Returns the y position (height) of this projectile."
return self.ypos
def getX(self):
"Returns the x position (distance) of this projectile."
return self.xpos
def main():
a, v, h, t = getInputs()
cball = Projectile(a, v, h)
zenith = cball.getY()
while cball.getY() >= 0:
cball.update(t)
if cball.getY() > zenith:
zenith = cball.getY()
print ("/n Distance traveled: {%0.1f} meters." % (cball.getY()))
print ("The heighest the cannon ball reached was %0.1f meters." % (zenith))
if __name__ == "__main__": main()