Arrays and copy semantics

Assignment Help Management Theories
Reference no: EM132191412

Part A) Arrays and copy semantics Consider the following Python code segment, which uses built-in Python lists and NumPy lists to perform similar operations, albeit with differing results.

Using built-in Python lists:

>>> data = [1, 2, 3, 4]

>>> print data [1, 2, 3, 4]

>>> otherData = data

>>> otherData[1] = -2

>>> print otherData [1, -2, 3, 4]

>>> print data [1, -2, 3, 4]

>>>

>>> otherData = data[1:3]

>>> print otherData [-2, 3]

>>> otherData[0] = 0

>>> print otherData [0, 3]

>>> print data Using NumPy arrays:

>>> import numpy as np

>>> data = np.array([1, 2, 3, 4])

>>> print data [1 2 3 4]

>>> otherData = data

>>> otherData[1] = -2

>>> print otherData [1 -2 3 4]

>>> print data [1 -2 3 4]

>>>

>>> otherData = data[1:3]

>>> print otherData [-2 3]

>>> otherData[0] = 0

>>> print otherData [0 3]

>>> print data [1 0 3 4]

Describe similarities and differences between copying and assignment semantics of built-in Python lists and NumPy arrays. Explain why the code behaves differently for the two.

Part B) Matrices NumPy also supports matrices. However, there are some important differences between two-dimensional arrays and matrices. Consider the following two code segments that are similar, but produce different results: Using NumPy two-dimensional arrays:

>>> A = np.array([[1,2], [3,4]])

>>> B = np.array([[2,1], [-1,2]])

>>> A * B array([[ 2, 2], [-3, 8]])

>>> A ** 3 array([[ 1, 8], [27, 64]])

Using NumPy matrices:

>>> A = np.matrix([[1,2], [3,4]])

>>> B = np.matrix([[2,1], [-1,2]])

>>> A * B matrix([[ 0, 5], [ 2, 11]])

>>> A**3 matrix([[ 37, 54], [ 81, 118]])

Describe similarities and differences between NumPy two-dimensional arrays and matrices. Explain why the code behaves differently for the two.

Reference no: EM132191412

Questions Cloud

What are the key takeaways : Reflection on what you learned from success and how it help you in your life and your school .
Review problem related to course conclusion : You have just completed 10 weeks of a computer and interaction design course. Imagine you have been asked to create a one-day training course highlighting.
Different personal-positional power types within leadership : In reference to the different personal and positional power types within leadership; Is expert power the best? Why or why not?
How will you manage these challenges in order to achieve : Which goal or goals do you think will be your greatest challenge? Why? How will you manage these challenges in order to achieve your goals?
Arrays and copy semantics : Consider the following Python code segment, which uses built-in Python lists and NumPy lists to perform similar operations, albeit with differing results.
What you have just learned within the past weeks : You have just completed ten (10) weeks of a mobile programming course. Imagine you have been asked to create a one-day training course that highlights.
Describe a time in your life in which you were engaged : Describe a time in your life in which you were engaged in a situation with someone of a different culture and how those differences complemented.
Which functional dependency causes bcnf violation : List candidate key(s), and how you found the key(s). Which functional dependency causes BCNF violation?
Create a policy and processes document for computer lab : You have been hired to perform computer investigations and forensics analysis for a company. You find that no policies, processes, or procedures are currently.

Reviews

Write a Review

Management Theories Questions & Answers

  Can vanoni make the delivery of the remaining specimens

Can Vanoni make the delivery of the remaining 12,000 specimens consideration in a new agreement with the Institute? Explain.

  Understanding tourism and international hospitality

Understanding Tourism and International Hospitality

  Pioneers are specialists of progress

Pioneers are specialists of progress; persons whose demonstrations influence other people.Just as an adolescent gets to be started into adulthood, a grown-up might pick up start as a pioneer. Pioneers have extraordinary impact over the country and pa..

  Briefly discuss limitations and advantages of each medium

List several media that might be effective for reaching consumers in a developing nation with low per capita income and a high level of illiteracy.

  How would you use amazon mechanical turks

Use your favorite search engine to find the definition of "Amazon mechanical Turk." If you were conducting a text mining study, how would you use Amazon mechanical Turks?

  Competitive bid underwriting and a negotiated underwriting

Competitive bid underwriting and a negotiated underwriting.

  Book report on laws of leadership

Book Report on "Laws of Leadership" by John Maxwell. You can either get the book by purchase, borrow or a library. You may also listen to the audiobook on Youtube

  Make key business decisions for accuracy of key spreadsheets

"Spreadsheets, even after careful development, contain errors in 1 percent or more of all formula cells," according to Ray Panko, a professor of IT management.

  Policy calling for the random drug testing

A state mental health department adopted a policy calling for the random drug testing of all of its employees. Three employees objected to the policy and sought a court order declaring it unconstitutional as applied to them.

  Why do many department stores seek a mark-up

Why do many department stores seek a markup of about 30% when some discount houses operate on a 20% markup? Identify and explain at least three reasons

  Write down the product specifications

Based on these data, should the company conclude that it is meeting the product specifications? Explain your reasoning.

  Develop an spc checklist for your selected company

To complete this part of the project, complete the following tasks: Develop an SPC checklist for your selected company and product. Using the Theory of Constraints, develop a checklist you can use to evaluate the product

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd