Python入门数学类编程 您所在的位置:网站首页 牛顿万有引力定律的应用 Python入门数学类编程

Python入门数学类编程

2024-03-06 22:31| 来源: 网络整理| 查看: 265

牛顿万有引力定律:质量m1的物体吸引另外一个质量m2的物体的力F, F=Gm1m2/r^2 其中,r是两个物体之间的距离,G是引力常数,G=6.674x10^-11 NM2kg-2 现在,我们预备计算距离从10-100之间,按5m距离递增的引力,并绘制出图形。

# -*- coding: utf-8 -*- """ Created on Thu Jan 6 18:38:31 2022 @author: 脂砚斋 """ import matplotlib.pyplot as plt #draw the graph def draw_graph(x,y): plt.plot(x,y,marker='o') plt.xlabel('distance in meters') plt.ylabel('Gravitation force in newtons') plt.title('Gravitation force and distance') plt.show() def generate_F_r(): r=range(10,101,5) F=[] G=6.674*(10**-11) m1=0.5 m2=1.5 for dist in r: force = G*(m1*m2)/(dist**2) F.append(force) draw_graph(r,F) if __name__=='__main__': generate_F_r()

在这里插入图片描述



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有