Skip to Content
A Concise Introduction to Programming in Python
book

A Concise Introduction to Programming in Python

by Mark J. Johnson
December 2011
Beginner
217 pages
8h
English
Chapman and Hall/CRC
Content preview from A Concise Introduction to Programming in Python
Chapter 25
Related Classes
Classes may also be related to each other through a mechanism called in-
heritance. When one class inherits from another, it inherits all the state and
behavior of the original class, and then has the opportunity to define addi-
tional new state and behavior.
The Sierpinski triangle is an interesting mathematical object (a fractal,
like the Mandelbrot set) that is constructed by rep eatedly removing the middle
from a solid triangle.
Listing 25.1: Sierpinski Triangle
1 # sierpinski.py
2
3 from turtle import Turtle, setworldcoordinates, exitonclick
4
5 class SierpinskiTriangle(Turtle):
6 size = 2
7 def __init__(self, n, x, y):
8 Turtle.__init__(self, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python Standard Library

Python Standard Library

Fredrik Lundh
Numerical Computing with Python

Numerical Computing with Python

Pratap Dangeti, Allen Yu, Claire Chung, Aldrin Yim

Publisher Resources

ISBN: 9781439896952