它不会给出正确的输出(Python新手)

问题描述 投票:0回答:1

它给出了一个意外的错误,“矢量 A 的大小”

对Python真的很陌生,所以请原谅我触发了优点

import numpy as np
def vector (X , Y, Z):
    X = int
    Y = int 
    Z = int
    return np.array([X , Y, Z])


Vector_A = np.array(input("Enter Your vector in X op Y op Z"))

def Magnitude_vector(A):
    A = np.array([X, Y, Z])
    import math 
    
    X = int
    Y = int 
    Z = int

    L = math.atan(Y/X)
    S = math.sqrt(X*X + Y*Y + Z*Z)
    M = (S/L)
    print(M)

print ("Magnitude of verctor A", Magnitude_vector)

输出应为 5.05 输入 ([3, 4, 5])

python math vector calculator
1个回答
0
投票

你好,我对向量不太了解,但通过阅读你的代码,我猜你正在尝试使用 X,Y,Z 来计算一些东西。我得到它的工作这里的代码=]

真的希望这有帮助=}

import math


X = int(input())
Y = int(input())
Z = int(input())


def Magnitude_vector(X, Y, Z):
    L = math.atan(Y/X)
    S = math.sqrt(X*X + Y*Y + Z*Z)
    M = (S/L)
    return M


print("Magnitude of verctor A is", Magnitude_vector(X, Y, Z))
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.