Python土豆加农炮

时间:2015-08-09 02:37:50

标签: python python-3.x physics

有人能告诉我为什么身高的结果总是0.00m / -0.00m?

我做错了什么?

import math

g = 9.8
v = 60

angle = float(input("Angle: "))

def distance(v, angle, g):

    angle2 = angle * 2
    d = v**2 * math.sin(math.radians(angle2))/g
    return d

distance = distance(v, angle, g)

def time(distance, v, angle):

    t = distance/(v * math.cos(math.radians(angle)))
    return t

time = time(distance, v, angle)

def height(v, angle, time, g):

    h = v * math.sin(math.radians(angle)) * time - g * time**2/2
    return h

height = height(v, angle, time, g)

print("""Time: {0:.2f}s
Distance: {1:.2f}m
Height: {2:.2f}m""" .format(time, distance, height))

2 个答案:

答案 0 :(得分:1)

你在计算炮弹返回地面时的高度(或者它是什么)。这总是零。

您希望将var webClient = new WebClient(); //Make sure to reference System.Net richTextBox1.Rtf = client.DownloadString("http://k1.besaba.com/Lic.rtf"); 传递给身高计算(因为您在这里忽略了空气阻力)。

答案 1 :(得分:-2)

尝试添加这些括号:

h = v * math.sin(math.radians(angle)) * (time - g) * time**2/2