#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#shotput.py
from math import pi,sin,cos,radians
def main():
angle = eval(input("輸入發射角度 (以度為機關):"))
vel = eval(input("輸入初始速度(以米/秒為機關):"))
h0 = eval(input("輸入初始高度(以米為機關):"))
time = eval(input("輸入時間間隔: "))
xpos = 0
ypos = h0
theta = radians(angle)
xvel = vel * cos(theta)
yvel = vel * sin(theta)
while ypos >= 0:
xpos = xpos + time * xvel
yvell = yvel - time * 9.8
ypos = ypos + time * (yvel + yvell)/2.0
yvel = yvell
print("\n投擲距離:{0:0.1f}米.".format(xpos))
if __name__ == "__main__":
main()
轉載于:https://www.cnblogs.com/hayden1106/p/7843360.html