Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele What are magic methods? | Magic Methods
In-Depth Python OOP
course content

Kurssisisältö

In-Depth Python OOP

In-Depth Python OOP

1. OOP Concepts
2. Inheritance
3. Encapsulation
4. Polymorphism and Abstraction
5. Magic Methods

book
What are magic methods?

12345678910111213
class Road: def __init__(self, length): self.length = length def __add__(self, other_road): return Road(self.length + other_road.length) road_1 = Road(20) road_2 = Road(30) road_3 = road_1 + road_2 # road_3 = road_1.__add__(road_2) print(type(road_3)) print(road_3.length)
copy
question mark

Select the correct answer

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 5. Luku 1

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

course content

Kurssisisältö

In-Depth Python OOP

In-Depth Python OOP

1. OOP Concepts
2. Inheritance
3. Encapsulation
4. Polymorphism and Abstraction
5. Magic Methods

book
What are magic methods?

12345678910111213
class Road: def __init__(self, length): self.length = length def __add__(self, other_road): return Road(self.length + other_road.length) road_1 = Road(20) road_2 = Road(30) road_3 = road_1 + road_2 # road_3 = road_1.__add__(road_2) print(type(road_3)) print(road_3.length)
copy
question mark

Select the correct answer

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 5. Luku 1
some-alt