Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
- What Are Objects And Classes? 2:45
- OOP Vocabulary Quiz 1 5 questions
- Let's Make a Class! 4:21
- Your first class 2 objectives
- Methods 5:48
- Your first method 1 objective
- Method Arguments 5:33
- Method Interactivity 1 objective
- __init__ 2 objectives
- Design 3:40
- OOP Basics 5 questions
- Master Class 3 objectives

- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
We can give our class some special abilities by defining methods for it.
You don't have to call the instance argument self
if you don't want to. It's not a required name but it's a very common convention (I don't think I've ever seen code that didn't).
class Thief:
sneaky = True
def pickpocket(instance):
if instance.sneaky:
return bool(random.randint(0, 1))
return False
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up-
Hanwen Zhang
20,084 Points1 Answer
-
Hanwen Zhang
20,084 Points1 Answer
-
Elena Chen
1,503 Points1 Answer
-
James Ball
2,074 Points1 Answer
-
PLUS
Tiana Manzano
Courses Plus Student 2,248 Points1 Answer
-
Anthony Piscocama
4,328 Points1 Answer
-
anthony pizarro
1,983 Points1 Answer
-
Muhammad Umar
7,906 Points1 Answer
-
Zach Daniels
1,606 Points2 Answers
-
rhupp
11,019 Points3 Answers
-
craigs love
Python Web Development Techdegree Student 96 Points1 Answer
-
Michael Cook
Full Stack JavaScript Techdegree Graduate 28,975 Points1 Answer
-
Hai Phan
2,442 PointsWhat is the difference between kenneth.pickpocket() and Thief.pickpocket(arg) exactly?
Posted by Hai PhanHai Phan
2,442 Points2 Answers
-
Hanna Han
4,105 Points2 Answers
-
Hanna Han
4,105 Points1 Answer
-
Kevin S
Data Analysis Techdegree Student 15,862 Points2 Answers
View all discussions for this video
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up