CP164 Study Guide - Final Guide: Alex Proyas, Data Element, Binary Search Algorithm
def write(self, fv):
"""
-------------------------------------------------------
Writes a single line of movie data to an open file fv
in the format
title|year|director|rating|code
Use: movie.write(fv)
-------------------------------------------------------
Parameters:
fv - an already open file of movie data (file)
Returns:
None
-------------------------------------------------------
"""
# Your code here
The only way to create a Movie object is to call the Movie constructor and pass it the proper
parameters. The following string contains movie data:
Dark City,1998,Alex Proyas,7.8,0
but this string is not a Movie object.
If, however, we call the Movie constructor and pass it this same data:
from Movie import Movie
some_movie = Movie('Dark City', 1998, 'Alex Proyas', 7.8, [0])
then the variable some_movie is a Movie object, because it was created by calling the Movie
constructor.
- Data Structure ADTs
The data storage classes we have seen so far, such as Student and Food, are designed to
hold a single piece of data. That data may have many attributes and methods, both those
attributes and methods taken together are still designed to worth with a single data
element. A data structure ADT is designed to hold multiple pieces of data, whether simple
values such as integers or strings, or more complex objects such as as Students or Foods.
A data structure ADT must have the following properties:
• it must be initialized before it can be used
• an instance of an ADT should work with one type of data only
find more resources at oneclass.com
find more resources at oneclass.com