CSC148H5 Lecture Notes - Lecture 1: Object-Oriented Programming, Procedural Programming, Instance Variable

57 views1 pages
1 Apr 2018
School
Course

Document Summary

The program is mainly a description of procedures. Do this, do this, then do this . Object-oriented programming the program is mainly a description of objects and their relations. A student has a student number, a utorid and can take courses, drop courses , etc; a classroom has a podium, desks and students . Rather than take_course(stu, course), we do stu. take_course(course) Better suited for modelling the real world. Oo is not always better than procedural, e. g. , sqrt(9) is better than 9. sqrt() We can already create some types of objects using the built-in object types, e. g. , string, list, dict . But sometimes, we want more types of objects, e. g. , student, building, game, circle . You can add a new type in python by defining a new class. Then you can instantiate an object of that class. Class names are nouns: student, course, rectangle, animal, cat, ship, (and str, list, dict!) A class"s definition consists of methods and attributes.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents