Radius is not a local variable it is an instance

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: True if object is an instance of class and False otherwise >>> isinstance("Hello", str)! True! >>> isinstance("Hello", float)! False! >>> isinstance([1,2,3], list)! True! >>> isinstance([1,2,3], dict)! False! 16 A Circle class • In order to create a Circle object, we might write something like this: radius = 40 shape = Circle(radius) • What methods should be in the Circle class? • What member variables should be in the Circle class? 17 Constructor – Circle class • The first method inside the class is the constructor (__init__) • The constructor iniDalizes the member data, and must be passed a reference to the object with self. • NOTE: The arguments of the constructor match the parameters of the __init__ method without self. 18 6 13 ­11 ­13 Other Methods inside the Circle class def get_perimeter(self): return 2*self.radius*math.pi def get_a...
View Full Document

This document was uploaded on 03/02/2014.

Ask a homework question - tutors are online