Question: This assignment will be partially graded by an automated test script. When a file or variable name is explicitly named in the assignment ( e

This assignment will be partially graded by an automated test script. When a file or variable name
is explicitly named in the assignment (e.g. hw1_complete.py, average_age), be sure to use the
correct name, so the test script can identify that you have done the task.
A. Copy it into a file hw1_complete.py and run it. It should print out several names and tell how
long each name is.
B. Use a list comprehension to create a list of lengths of the names. Here is an example list
comprehension. This is quite a powerful feature; search around the web for more complex
examples.
C. Create a separate file, named "
person.py". In that file, define a class "person" with fields "name",
"age", and "height." Define the method (constructor) that takes arguments 'name', 'age',
and 'height', and sets the object variables of the same names. Eg.
should create an object named "new_person" with the name, age, and height indicated and
then print out "Joe is 34 years old."
D. Add a method "(self)" that returns a string of this form: "Bob is 17 years old and 182
cm tall".
E. Back in the main file hw1_complete.py, add a line to "import person". Then iterate through the
names and create a dictionary named "people" where the key is a name, and the value is a
person object.
F. Use numpy.array() to convert the list of ages into an array. Repeat for the list of heights.
G. Use the numpy.mean() function to find the average age of the people in your list and put that
average age in a variable named average_age.
H. Use matplotlib to create a scatter plot of ages (on the x axis) and heights (on the y axis). Add
gridlines, x and y axis labels, and a title. Export the plot as a png file.
I. There is already code in the template to load the 'iris' dataset and to make one plot of it.
Explore the data.
J. Write a function named classify_iris() that implements a linear classifier for the iris dataset.
You'll have a 34 array of weights and a 3-element vector of biases. The function will take a 4-
D vector of features as its only argument and return an integer label , or 2
 This assignment will be partially graded by an automated test script.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!