
F6-CS OOP
Presentation
•
Computers
•
12th Grade
•
Practice Problem
•
Medium
Adrien Ebitner
Used 4+ times
FREE Resource
20 Slides • 2 Questions
1
2
method of structuring a program
using individual objects
think of it like components of a system
an object contains data
3
is a programming paradigm (way to classify programming language based on)
strucutre like objects
For e.g. an object could represent a person
with properties like name, age, address
behaviors such as walking, talking, breathing, etc.
4
Create a class
using class to create new objects
model systems with class inheritance
5
why do we need classes?
sometimes we need classes for many reasons
remember list in Python?
look at this list
pikachu = [electric, ground, [electric, fly, steel], 35, 55, 40, 50, 50, 90]
many issues
6
pikachu = [electric, ground, [electric, fly, steel], 35, 55, 40, 50, 50, 90]
when the list gets long, will you remember the element with index 5 mean?
what if you have another list but, it is shorter?
it is too inconsistent
7
class Dog:
pass
usually PascalCase
8
9
class Dog:
def __init__(self, name, age):
self.name = name
self.age = age
__init__ is an intance method that initializes a newly created object. It takes the object as its first argument followed by additional arguments.
10
class Dog:
def __init__(self, name, age):
self.name = name
self.age = age
attributes created in .__init__() are called instance attributes. Meaning all Dog objects have a name and an age, but the values may vary
11
class Dog:
# Class attribute
species = "Canis familiaris"
def __init__(self, name, age):
self.name = name
self.age = age
12
class Dog:
# Class attribute
species = "Canis familiaris"
Class attributes are different, where all class attributes are directly beneath the first line of the class name. All class instances will have the same value for class attributes.
13
buddy = Dog("Buddy", 9)
miles = Dog("Miles", 4)
These create two new Dog instances
Why we don't need 3 arguments?
When creating a new instance, python will pass the instance to the first paramter of .__init__()
14
15
You can change the different instance's attribute's value
>>buddy.age = 10
>>buddy.age
10
>>miles.species = "Felis silvestris"
>>miles.species
'Felis silvetris'
16
Fill in the Blanks
What is the line to create a new class called School?
17
Fill in the Blanks
Type the way to define the method for init incluiding the following arguments excluding self, (vehicleId, Engine)
hint: ?? __init__(??, ??, ??):
18
A process by which the methods and data from one class, superclass or base class, are copied to another class, a derived class
19
Write a short program to declare a class, student, with the private attributes name, dateOfBirth and examMark, and the public method displayExamMark. Declare an object myStudent, with a name and exam
mark of your choice, and use your method to display the exam mark.
20
21
22
Show answer
Auto Play
Slide 1 / 22
SLIDE
Similar Resources on Wayground
17 questions
Reading Comp Questions
Presentation
•
12th Grade
19 questions
Plano Cartesiano!!
Presentation
•
12th Grade
17 questions
PyGame: Primitives
Presentation
•
12th Grade
17 questions
Chapter 1 Quiz
Presentation
•
University
17 questions
health and safety
Presentation
•
12th Grade
15 questions
Personal & Public Communication Revision
Presentation
•
12th Grade
15 questions
10 сынып информатика
Presentation
•
12th 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