Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a Jupyter notebook called hw1.yourlastname ipynb where you replace yourlastname with your actual last name. After completing parts 1-3, upload your iPython notebook to

image text in transcribed
Create a Jupyter notebook called hw1.yourlastname ipynb where you replace yourlastname with your actual last name. After completing parts 1-3, upload your iPython notebook to Canvas. Use your iPython notebook to demon- strate that your functions work, ie that you have tested them. Also organize your notebook using headers and text as necessary to separate the different problems. See the sample output in this Jupyter notebook. Note the last problem needs two methods from the math module. 4 Write a function 1ist.to.dictionary that takes a list 1 and returns it as a dictionary. Assuming the list has the structure 1 "-keyi ,value 1, key2 , value2, key3, value3, . . .] so that the function returns the dictionary { key1:value1, key2:value2, key3:value3, ...). Also write the inverse function dictionary.to.list that takes a dictionary d and returns a list as an alternating series of keys and values. 5. Write a function angle.betveen.vectors that takes two lists of numbers vi and v2 that ve vill use as vectors. The function vill compute the angle betveen v1 and v2. The default value of v2 should be None. If it is None, then v2will be assigned as many ones as the length of vi. For instance if v11,21 then the second vector would be treated as [1,1 If vi were [1,2,3] then v2 would be assigned [1,1,1. Otherwise if v2 has a different value than None passed in, then the method should first check that vi and v2 have the same length and raise an Exception if they do not. The angle (theta) betwen two vectors th and v2 can be obtained froin the formula cos(0)()/V/ Hint: read the lecture notes fot dot products. Sample runs using these functions are below

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

Practical Azure SQL Database For Modern Developers Building Applications In The Microsoft Cloud

Authors: Davide Mauri, Silvano Coriani, Anna Hoffma, Sanjay Mishra, Jovan Popovic

1st Edition

1484263693, 978-1484263693

More Books

Students also viewed these Databases questions