






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Key points in this Introduction to Computing Using Python lecture are: Using Classes, Objects, Data in Folder, Attributes, Types, Classes Are Types for Objects, Objects Can Have Methods, Machinery, Class Definition, Method Calls, Initializing Instances, Constructor Expression . Objectives of this course are: 1.Fluency in (Python) procedural programming 2. Competency in object-oriented programming 3. Knowledge of searching and sorting algorithms
Typology: Slides
1 / 10
This page cannot be seen from the preview
Don't miss anything!







class Time(object): """Instances represent times of day. Instance variables: hour [int]: hour of day, in 0..23" min [int]: minute of hour, in 0.. """ def init(self, hour, min): """The time hour:min." Pre: hour in 0..23; min in 0..59""" def increment(self, hours, mins): """Move this time
class Rectangle(object): """Instances represent rectangular" regions of the plane. Instance variables: t [float]: y coordinate of top edge" l [float]: x coordinate of left edge" b [float]: y coordinate of bottom edge" r [float]: x coordinate of right edge For all Rectangles, l <= r and b <= t. """ def init(self, t, l, b, r): """The rectangle [l, r] x [t, b] Pre: args are floats; l <= r; b <= t""" def area(self): """Return: area of the rectangle.""" def intersection(self, other): """Return: new Rectangle describing intersection of self with other.""" class invariant States what attributes are present and what values they can have. A statement that will always be true of Rectangle instances. method specification States what the method does. Gives preconditions stating what is assumed to be true of the arguments.
Instance variables: hour [int]: hour of day, in 0..23" min [int]: minute of hour, in 0..
def init(self, hour, min): """The time hour:min." Pre: hour in 0..23; min in 0..59"""
self.hour = hour self.min = min
§ interface between two programmers § interface between two parts of the program