
Intro to Object Oriented Programming: Class Attributes
Presentation
•
Computers
•
6th - 8th Grade
•
Practice Problem
•
Medium
Kimberly Lewis
Used 6+ times
FREE Resource
15 Slides • 5 Questions
1
2
What are some things each of them has?
3
Name
Age
Height
Weight
Hair color
Eye color
Skin color
4
If we think about data types, we could consider doing all of this in lists based on individuals. Then we can pull the information from the list.
Lists
5
Every list is new information!
How big can we really make the lists?
What if you don't have the same number of fields?
No inheritance (we'll cover this later!)
Cons
You've done it before
Relatively simple
Pros
6
Classes let us make smaller files, and more advanced programs
7
Let's look at the Enterprise crew as a class.
8
An instance is a single crew member.
9
A class is a blueprint.
The instance is the actual data.
10
Multiple Choice
You want to create a game that has several people playing at once. Should you build it using a list for each player or a class?
Lists
Class
11
Multiple Choice
Your game has a bunch of different food items the characters eat to gain health. Would you create a class just for the food?
Yes
No
12
Multiple Choice
Now you plan on having players fight monsters in the game. Should the monsters have their own class?
Yes
No
13
We start by adding the class statement. This tells python that everything after it is a class. Then we name it. pass is just a way to tell the code that there will be code here.
So how do we code it?
14
We create a function called __init_ that we add some of the properties we want in all of the dogs.
Now we give it properties.
15
These are called arguments. This is telling the code exactly how many and where we will be specifying this information when we make our instance. It reminds the code what it needs when you make an instance, and where to put that information.
16
The code self.name = name creates an attribute called "name" and assigns the value of the variable "name" to it. The same goes for the age and the breed.
Back to the code...
17
Fill in the Blanks
Which piece of code creates the attribute "name" and assigns it the value "name"? Write the actual code, not the line number!
18
Just like when we call a function, we put the name of the class with the parentheses to tell the computer we're creating a new instance. But look at the red squigglies! We're not done yet!
Running the class
19
Now we add our instance information to the class in the parentheses! We have an instance of Dog()!
We add the variable information here!
20
Multiple Choice
What's wrong with the code here?
Nothing
You're calling a function with a variable
You haven't added the instance values to the class
The name in the variable isn't capitalized
Show answer
Auto Play
Slide 1 / 20
SLIDE
Similar Resources on Wayground
17 questions
Computer Software
Presentation
•
7th Grade
15 questions
Context Clues
Presentation
•
6th - 8th Grade
15 questions
Natural Selection
Presentation
•
6th - 8th Grade
15 questions
Independent & Dependent Variables
Presentation
•
6th - 8th Grade
15 questions
Respiratory System
Presentation
•
6th - 8th Grade
15 questions
LCM and GCF Review
Presentation
•
6th - 8th Grade
15 questions
Informational Summary Writing
Presentation
•
6th - 8th Grade
13 questions
Google Sheets Basics
Presentation
•
6th - 9th Grade
Popular Resources on Wayground
10 questions
Safety Day 2026 – Student Review
Quiz
•
9th Grade
21 questions
Continents and Oceans
Quiz
•
6th Grade
20 questions
Parts of Speech
Quiz
•
5th Grade
16 questions
Subject & Predicate
Quiz
•
5th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
12 questions
Map Skills
Quiz
•
3rd Grade
22 questions
Continents and Oceans
Quiz
•
5th Grade
15 questions
Rounding Decimals
Quiz
•
5th Grade