10. More Objects - 10 MORE OBJECTS Rocky K C Chang(Based on...

Info icon This preview shows pages 1–7. Sign up to view the full content.

10. MORE OBJECTS Rocky K. C. Chang October 18, 2015 (Based on from Charles Dierbach. Introduction to Computer Science Using Python and adapted from John Zelle's slides)
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

Objectives Explain the difference between a reference and dereferenced value. Describe the use of object references. Explain the concept of memory allocation and deallocation. Effectively use objects in Python. Explain the relationship between class and objects.
Image of page 2
Objects in Python All values in Python are represented as objects, including lists, as well as numeric values. Rocky Chang Methods split() lower() upper() capitalize() Data A string object student Your program
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

EXERCISE 10.1 Try list1 = ["CBS", "NBC", "ABC"] list2 = [4, 1, 2, 3] list3 = ["CBS", "NBC", "ABC", 4, 1, 2, 3] sorted(list1); sorted(list2); sorted(list3) list1.sort(); list2.sort(); list3.sort() More on sorting:
Image of page 4
Procedural vs object-oriented An object contains a set of attributes, stored in a set of instance variables , and a set of functions called methods that provide its behavior. sort() is a function. sort() is a method for a list object. Source: Charles Dierbach. 2013. Introduction to Computer Science Using Python. Wiley.
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

Object references In Python, objects are represented as a reference to an object in memory.
Image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern