Write a program named vector_math.py that lets a user enter two vectors, A and B, of...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a program named vector_math.py that lets a user enter two vectors, A and B, of the same arbitrary length and store each vector as a Python list. Have the user enter each vector in one line with spaces between elements. Then, you should output the results of these computations using the format shown below. Print any resulting lists to include [] and,. The magnitude of vector A and the magnitude of vector B printed to five (5) decimal places A + B • • • A-B The dot product (inner product) of A and B printed to two (2) decimal places Note: You should use lists (and loops) when solving this problem. You may NOT use sympy or numpy. Later we will see some other ways to work with vectors more directly. Example output using vectors A = [1, 2, 3] and B = [4, 5, 6]: Enter the elements for vector A: 1 2 3 Enter the elements for vector B: 4 5 6 The magnitude of vector A is 3.74166 The magnitude of vector B is 8.77496 A + B is [5.0, 7.0, 9.0] A - Bis [-3.0, -3.0, -3.0] The dot product is 32.00 Write a program named vector_math.py that lets a user enter two vectors, A and B, of the same arbitrary length and store each vector as a Python list. Have the user enter each vector in one line with spaces between elements. Then, you should output the results of these computations using the format shown below. Print any resulting lists to include [] and,. The magnitude of vector A and the magnitude of vector B printed to five (5) decimal places A + B • • • A-B The dot product (inner product) of A and B printed to two (2) decimal places Note: You should use lists (and loops) when solving this problem. You may NOT use sympy or numpy. Later we will see some other ways to work with vectors more directly. Example output using vectors A = [1, 2, 3] and B = [4, 5, 6]: Enter the elements for vector A: 1 2 3 Enter the elements for vector B: 4 5 6 The magnitude of vector A is 3.74166 The magnitude of vector B is 8.77496 A + B is [5.0, 7.0, 9.0] A - Bis [-3.0, -3.0, -3.0] The dot product is 32.00
Expert Answer:
Answer rating: 100% (QA)
Heres a Python program named vectormathpy that performs the specified operations python import math ... View the full answer
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
When deciding whether to accept or refuse a medical treatment on behalf of an infant, which standard should a parent use? Give an argument that explains and justifies your answer.
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in...
-
c++. error: array must be initialized with a brace enclosed initializer main.cpp X 10 11 ii 12 13 14 4567 15 16 17 18 19 287288285 20 21 23 24 25 26 27 28 25285922223288 30 31 33 34 36 37 40 41 42 43...
-
A shaving/makeup mirror is designed to magnify your face be a factor of 1.33 when your face is placed 20.0 cm in front of it. (a) What type of mirror is it? (b) Describe the type of image that it...
-
1. Reflect on why India has become such an important growth market for online shopping companies. Discuss the importance of first-mover advantages in India. How is Amazon positioning itself to...
-
What are the criteria used for estimating the total effort required by a salesperson to cover a territory?
-
The adjusted trial balance of Amana Corporation at December 31 shows that sales revenue for the year was $513,000 and other revenue was $37,000. Cost of goods sold for that same period was $256,000,...
-
What is the importance of time (n) number of years in TVM? What is the importance of the interest rate (R) in TVM? What is the importance of the initial amount of money someone chooses to invest (PV)
-
Consider the following costs for a certain chemical product: Fixed cost: $2.045 million/year. Variable costs: Material cost: 62 cents per gallon of product. Energy cost: 24 cents per gallon of...
-
The following information relates to DFW Corporation, a local wholesale company: All sales are on account and are budgeted as follows: January, $710,000; February, $400,000. DFW typically collects...
-
How is the relationship of a tenant affected by his landlords sale of her interest to a purchaser? What is the nature of the new relationship?
-
What is meant by apparent authority?
-
What is the function of a corporations stated capital account?
-
Explain the importance of renewal clauses in business leases.
-
In what ways is the liability of a partner in an LLP limited?
-
4. Which of the following are valid? (a) Inu - 2 = In - e (b) 3+ Inv=In UV (c) Inu+Inv-In w = in- (d) In 3+In 5 = In 8 1
-
A 20-cm-square vertical plate is heated to a temperature of 30oC and submerged in glycerin at 10oC. Calculate the heat lost from both sides of the plate.
-
Suppose we can buy a chocolate bar from the vending machine for $1 each. Inside every chocolate bar is a coupon. We can redeem six coupons for one chocolate bar from the machine. This means that once...
-
Write a class ContactInfo to store contact information for a person. It should have attributes for a persons name, business phone, home phone, cell phone, e-mail address, and home address. It should...
-
Do Programming Project 17 from Chapter 4, the Edoc calculator, except write a method that takes the number of candy, Edoc, and Margorp as input parameters and returns the amount of experience that...
-
Some people argue that the government should not intervene in the case of a market failure because the government itself is inefficient and will simply create new problems to replace the ones it is...
-
Consider each of the following issues and discuss whether you support Theory X, Theory Y, neither theory, or some combination of them. Issue Theory X Theory Y Whether a person is healthy or sick...
-
Looking at Medicaids traditional eligibility rules, you will notice numerous value/policy judgmentspregnant women and children are favored over childless adults, the medically needy are favored over...
Study smarter with the SolutionInn App