Lecture13-ClassImplementation-Part1-3pp

Lecture13-ClassImplementation-Part1-3pp

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: other process • A string object knows how to make itself lowercase, we don’t have to pass the string to a funcDon to do that for us   ie. “Hello”.lower() not lower(“Hello”)! 4 Classes • A class is a descripDon of a data type (e.g., integers, strings, floaDng point numbers, …) • We can write our own classes in Python… • … and so we can define our own types! • Classes contain data and funcDonality related to the new type 5 Instances • The “values” of that type are called instances of the class instance 5 ‘cat’ -8 37 10 128 221 ‘a’ ‘kayak’ ‘Bob’ ‘took’ … class of integers … class of strings 10.0 2.718 6.1 -3.5 3.14159 8.7 … class of floaDng point numbers 6 2 13 ­11 ­13 Instances # my_str and “Hello” are instances of the 
 # string class
 print(“Hello”)
 my_str = “World”! ! # my_list is an i...
View Full Document

This document was uploaded on 03/02/2014.

Ask a homework question - tutors are online