本文实例讲述了python计算三维矢量幅度的方法。分享给大家供大家参考。具体如下:
from numpy import *
from math import *
a=(['x','y','z'])
sum_com=0
for i in range(3):
y=input("Enter %s component:"%a[i])
m=y**2
sum_com += m
magnitude=sqrt(sum_com)
print "The magnitude of vector is %s"%magnitude
希望本文所述对大家的Python程序设计有所帮助。
python怎么学习?python怎么入门?python在哪学?python怎么学才快?不用担心,这里为大家提供了python速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号