Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

using python Create a class to handle x,y,z vectors. The class should have the following features 1) create a vector using v = myvector(x,y,z) to

using python

Create a class to handle x,y,z vectors. The class should have the following features

1) create a vector using v = myvector(x,y,z) to initialize the vector

2) find the magnitude of the vector v.mag() returns the magnitude

2) add two vectors so v1=myvector(x,y,z) v2=myvector(x,y,z) v3 = v1+v2

3) v.format() returns a string of the form xi + yj + zk

4) perform cross product when vectors are multiplied v3 = v1 * v2 v3 is the cross product v1 and v2

Program structure

complex class definition here...

# ------------- Main -----------

a = vector(1,2,1)

b = vector(4,1,7)

print(a.format(), "Mag = ", a.mag())

print(b.format(), "Mag = ", b.mag())

print("a + b =", (a.add(b)).format())

print("a cross b = ", (a.cross(b)).format())

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Business Process Driven Database Design With Oracle PL SQL

Authors: Rajeev Kaula

1st Edition

1795532386, 978-1795532389

More Books

Students also viewed these Databases questions

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago