1 of 12

CSE 163

Objects

Arpan Kapoor�Summer 2026��💭Icebreaker (discuss with neighbors):

Favorite outdoor area in Seattle or Washington?

Add to our Slido!

slido.com

#2348882

2 of 12

Announcements

  • Programming Practice 3 due on Thursday at 11:59 PM!
  • Homework 3 - Education due on Friday at 11:59 PM!
  • Programming Practice 4 & Homework 4 - Networks release at the end of this week!
    • Homework 4 is your first 2 week long homework assignment
  • Resubmissions for Homework 1 now open!
    • Resubmission Cycle 1 (7/10 - 7/17) closes on Friday at 11:59 PM
    • MUST submit corresponding Google Form for resubmission to be graded!
    • See pinned Ed announcement for more details
  • Week 3 grades released

slido.com

#2348882

3 of 12

Lesson Recap

  • An object stores state and provides behaviors that operates on a state.
  • Each object has its own state, but objects of the same class can have the same behaviors.

State:

self.name

Behavior:

.thwip()

slido.com

#2348882

4 of 12

Objects

State:

self.name

Behavior:

.thwip()

spider_man = SpiderMan(‘Peter Parker’)

amazing_sm = SpiderMan(‘Peter Parker’)

slido.com

#2348882

5 of 12

Objects

spider_man = SpiderMan(‘Peter Parker’)

amazing_sm = SpiderMan(‘Peter Parker’)

Behavior:

.thwip()

spider_man

State:

‘Peter Parker’

Behavior:

.thwip()

amazing_sm

State:

‘Peter Parker’

slido.com

#2348882

6 of 12

Objects

spider_man = SpiderMan(‘Peter Parker’)

amazing_sm = SpiderMan(‘Peter Parker’)

spider_man.thwip()

Behavior:

.thwip()

spider_man

State:

‘Peter Parker’

Behavior:

.thwip()

amazing_sm

State:

‘Peter Parker’

slido.com

#2348882

7 of 12

References

spider_man = SpiderMan(‘Peter Parker’)

amazing_sm = spider_man

spider_man.thwip()

Behavior:

.thwip()

spider_man

State:

‘Peter Parker’

Behavior:

.thwip()

amazing_sm

State:

‘Peter Parker’

slido.com

#2348882

8 of 12

State:

‘Peter Parker’

Behavior:

.thwip()

spider_man = SpiderMan(‘Peter Parker’)

amazing_sm = spider_man

spider_man.thwip()

spider_man

amazing_sm

= SpiderMan(‘Peter Parker’)

slido.com

#2348882

9 of 12

Multiple References!

slido.com

#2348882

10 of 12

Class

  • A class lets you define a new object by specifying what state and behaviors it has
  • A class is a blueprint that we use to construct instances of the object

class SpiderFolk:

def __init__(self, name: str) -> None:

self.name: str = name

def thwip(self) -> None:

print(self.name + ‘: Thwip!')

A class definition

An initializer that sets fields (state)

A method (behavior)

slido.com

#2348882

11 of 12

s1 = SpiderFolk(‘Cindy’)

s2 = SpiderFolk(‘Jessica’)

s3 = s1

s1.thwip()

s2.thwip()

s3.thwip()

s1

name:

‘Cindy'

s2

name:

‘Jessica'

s3

slido.com

#2348882

12 of 12

What is self?

  • In the SpiderFolk example, every method (initializer or instance method) takes a parameter called “self”
  • This indicates which instance of the method is being called on

Who is self referring to for each call to thwip()?

class SpiderFolk:

def __init__(self, name):

self.name = name

def thwip(self):

print(self.name + ‘: Thwip!')

s1 = SpiderFolk(‘Cindy')

s2 = SpiderFolk(‘Jessica')

s3 = s1

s1.thwip()

s2.thwip()

s3.thwip()

slido.com

#2348882