Help!!! How to apply my created function to another function

djoyceb at gmail.com djoyceb at gmail.com
Sun Mar 10 14:30:07 EDT 2019


Please see the last line

When I put vectorMagnitude(A), it returns perfectly corrected that means my function create right. But when I try to put vectorMagnitude(B) which I was thinking to put new list from buildRandomVector(A),it returns an error. I have been attempting to import buildRandomVector(A) to a list, but I can not understand why the list can not apply to  vectorMagnitude(B).

Can you assist me in figuring the problem? Thank you!!

A = [ 4, 5, 1]

#TASK0

def displayVector(v) :

    print(v)

displayVector(A)

#TASK1

def buildVector(v) :

    print(v[0],v[1],v[2])

buildVector(A)

#TASK2

import random

def buildRandomVector(v) :

    Z = []

    for i in range(len(v)):

        x = (random.randint(0, 9))

        Z.append(x)

    print(Z)

buildRandomVector(A)

#TASK3

import math 

B = buildRandomVector(A)

def vectorMagnitude(v) :

    tsum = 0

    for i in v:

        tsum = tsum + i**2

        x = math.sqrt(tsum)

    print(x)

vectorMagnitude(B)  ==>>>> this is problem



More information about the Python-list mailing list