Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.
new_person = person (name= 'Joe', age=34, height=184) print ("{? is {? years old.". format(new_person. name, new_person.age)))
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 182cm 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
image text in transcribed

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_2

Step: 3

blur-text-image_3

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

Statistical And Scientific Database Management International Working Conference Ssdbm Rome Italy June 21 23 1988 Proceedings Lncs 339

Authors: Maurizio Rafanelli ,John C. Klensin ,Per Svensson

1st Edition

354050575X, 978-3540505754

More Books

Students also viewed these Databases questions