From the course: Python Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Solution: Drawing shapes

Solution: Drawing shapes - Python Tutorial

From the course: Python Essential Training

Solution: Drawing shapes

- [Presenter] Technically speaking, this challenge was the easiest because it had no wrong answers. It's arts and crafts day. Anything you do is great. But really I do hope you got some sort of triangle printed out. So let's take a look at our classes and a couple ways to do this. So here we have the base class shape. It's not a particular shape, it's just defining general properties of shapes. It has a default width and height of five. Sort of saying, "All shapes, all good basic shapes have a width and a height of five, because that's the sort of width and height that shapes in general should have." Sure, you can agree with that or not. Maybe you want to override it in an extending class. Then we have the print character. And so this is a hash. And this is just the character we use to print out the body of our ASCII art shapes. Then the print method. It iterates through the height, printing out one row at a time, calling print row with the sort of height index where zero is the top…

Contents