Question: Understand broadcast.py , a program that illustrates the concept of broadcasting. Create a Person class that contains two fields: a first name and a last

Understand broadcast.py, a program that illustrates the concept of broadcasting.
Create a Person class that contains two fields: a first name and a last name. Then create a numpy array that contains 5 Person(s). Finally, use the built-in sorted function to alphabetize the array using the last name as the primary key and the first name as the secondary key.
# --------------------------------------
# CSCI 127: Joy and Beauty of Data
# NumPy Computer Graphics "broadcast" example
# --------------------------------------
import turtle
import numpy as np
# --------------------------------------
def draw_house(stylus, coordinates, pen_color):
stylus.color(pen_color)
stylus.up()
stylus.goto(coordinates[0][0], coordinates[0][1])
stylus.down()
for coordinate in coordinates:
stylus.goto(coordinate[0], coordinate[1])
# --------------------------------------
def draw_neighborhood(drawing_turtle):
drawing_turtle.hideturtle()
coordinates = np.array([[-30,50],[-30,-50],[70,-50],[70,50],
[-30,50],[20,100],[70,50]])
draw_house(drawing_turtle, coordinates, "black")
draw_house(drawing_turtle, coordinates +10, "black")
draw_house(drawing_turtle, coordinates +[-100,-200], "red")
draw_house(drawing_turtle, coordinates *2, "turquoise")
draw_house(drawing_turtle, coordinates *[.5,.2]+[100,200], "blue")
# --------------------------------------
def main():
window = turtle.Screen()
house_turtle = turtle.Turtle()
draw_neighborhood(house_turtle)
window.exitonclick()
# --------------------------------------
main()

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 Programming Questions!