IT 117: Introduction to Scripting
Homework 8
Due
Sunday, November 2nd at 11:59 PM
What You Need to Do
- Create the script hw8.py
- Make sure it obeys the rules in
Rules for Homework Scripts
- Make sure the script has a hashbang line and is executable
- Move it to an an hw8
directory on pe15.cs.umb.edu
Setup On Your Machine
- Open a text editor.
I would suggest the text editor built into the program IDLE
.
- Save the file as hw8.py
Specification
- Define the class LP
- This class must have the following 3 attributes
- The class must have the following 4 methods
- __init__
- get_title
- get_label
- get_artist
- print_lp
Methods
__init__
get_title
- Header
def get_title(self):
- This method returns the value of the
title attribute
get_label
- Header
def get_label(self):
- This method returns the value of the
label attribute
get_artist
- Header
def get_artist(self):
- This method returns the value of the
artist attribute
print_lp
- Header
def print_lp(self):
- This method prints a string with the values of all
attributes with a comma, , between each
- The attributes should appear in the following order
Test Code
- Your script must contain the following statements
- They should appear at the bottom of your script
lp = LP("The London Concert", "Sony Classical", "Wynton Marsalis")
print(lp.get_title())
print(lp.get_label())
print(lp.get_artist())
lp.print_lp()
Output
Suggestions
Suggestions
- Write this script in stages
- Test your script at each step
- Print the steps below
- And check them off as you finish each one
-
Create the file hw8.py.
Write the class header for LP.
Write the constructor for this class.
Make sure the constructor has parameters for each attribute.
Make sure the constructor sets the value for each attribute.
Add the test code to the bottom of the script.
Comment out all but the first line of the script.
Run the script.
Fix any errors you find.
-
Create the method get_title.
Uncomment the second line of the test code to the bottom of the file.
Run the script.
Fix any errors you find.
-
Create the method get_label.
Uncomment the third line of the test code to the bottom of the file.
Run the script.
Fix any errors you find.
-
Create the method get_artist.
Uncomment the fourth line of the test code to the bottom of the file.
Run the script.
Fix any errors you find.
-
Create the method print_lp.
Uncomment the last line of the test code to the bottom of the file.
Run the script.
Fix any errors you find.
Testing on Your Machine
Copy the Script to Unix
- Open FileZilla and connect to
pe15.cs.umb.edu
- Go to your it117 directory
- Go to your hw directory
- Right-click in the whitespace inside the
hw directory
- Enter hw8 in the dialog box
- Click and drag your script from the bottom left panel
to the bottom right panel
- Right-click on the file and select "Permissions" from
the menu
- Enter 755 in the box provided
- This will make the script executable
Testing the Script on Unix (Optional)
Copyright © 2020 Glenn Hoffman. All rights reserved. May not be reproduced without permission.