From the course: Getting Started with Python Object Oriented Programming: A Hands-On Approach

Unlock the full course today

Join today to access over 24,900 courses taught by industry experts.

Challenge: Python object properties and methods

Challenge: Python object properties and methods

(upbeat music) - [Instructor] Now that you are familiar with class properties and methods, we're going to give you a challenge for this chapter. So the challenge is you're going to create a circle class, and this class is going to have a radius property and two methods. One is to display the circumference, and one is to display the area of a circle with a given radius. So if you remember your high school maths, the circumference of a circle is given by two times pi times the radius of the circle, and the area is given by pi times the radius squared. And for the purposes of this exercise, we can use a value of pi of 3.14. So we don't need to be accurate about this because maths is not the main issue here. Once you've created your class, I want you to create an instance of the circle with a radius of two units, and then I want you to test your methods and try and display the area and the circumference. If you look in your code space in the start folder and the folder for 02_03, you'll…

Contents