#!/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()