SUPER() in Python explained! 🔴

  Рет қаралды 13,340

Bro Code

Bro Code

Күн бұрын

Пікірлер: 40
@BroCodez
@BroCodez 6 ай бұрын
# super() = Function used in a child class to call methods from a parent class (superclass). # Allows you to extend the functionality of the inherited methods class Shape: def __init__(self, color, is_filled): self.color = color self.is_filled = is_filled def describe(self): print(f"It is {self.color} and {'filled' if self.is_filled else 'not filled'}") class Circle(Shape): def __init__(self, color, is_filled, radius): super().__init__(color, is_filled) self.radius = radius def describe(self): print(f"It is a circle with an area of {3.14 * self.radius * self.radius}cm^2") super().describe() class Square(Shape): def __init__(self, color, is_filled, width): super().__init__(color, is_filled) self.width = width def describe(self): print(f"It is a square with an area of {self.width * self.width}cm^2") super().describe() class Triangle(Shape): def __init__(self, color, is_filled, width, height): super().__init__(color, is_filled) self.width = width self.height = height def describe(self): print(f"It is a triangle with an area of {self.width * self.height / 2}cm^2") super().describe() circle = Circle(color="red", is_filled=True, radius=5) square = Square(color="blue", is_filled=False, width=6) triangle = Triangle(color="yellow", is_filled=True, width=7, height=8) circle.describe() square.describe() triangle.describe()
@naheeddeedar2792
@naheeddeedar2792 9 күн бұрын
you defined super() class excellent way that's great for me to understand easily Thanks
@gsrini27
@gsrini27 Ай бұрын
OMG!, you are the best tutor in Python. It’s in-depth and with script to test. Thank you for your time on making this series.👍
@younessid437
@younessid437 3 күн бұрын
Finally, I found the python itself explaining himself 😂 Thank You soooo much
@omisolveejaym.8885
@omisolveejaym.8885 6 ай бұрын
Really love your videos man!! Can you make a video about API? It is something I couldn't get my head into and I really love how you explain stuff, I might be able to grasp it this time. Thanksss❤️
@pokerchannel6991
@pokerchannel6991 Ай бұрын
I heard that inheritance can get messy. I heard it is to be used carefully.
@ysmainly
@ysmainly 2 ай бұрын
Found this really helpful in understanding inheritance, thank you Bro Code!
@fasgy410
@fasgy410 13 күн бұрын
What happens when you write self.color = color_name? I mean that the name after self. is different than one after =
@jahodamaty2206
@jahodamaty2206 Ай бұрын
Why the describe function is inherited, if the code is super().__init__(color, is_filled) shouldnt that just inherite the __init__ function and not the whole class? thanks for an answer :)
@actraveler8309
@actraveler8309 2 ай бұрын
Awesome!
@oni5556
@oni5556 18 күн бұрын
great video, very helpful - thank you bro code 💯
@S9J4
@S9J4 6 ай бұрын
Just a simple question, why your every video is a fundraiser and for what?
@zohaibwaris-q8x
@zohaibwaris-q8x 2 ай бұрын
Just a simple answer: probably it's for the channel these are the highest quality videos that I found on KZbin regarding programming so if people Wana support their favorite creator they can.
@omairtech6711
@omairtech6711 2 ай бұрын
​@@zohaibwaris-q8x Not for the channel itself; It's donated to a charity or something. Look it up.
@dinofish67
@dinofish67 Ай бұрын
fundraiser is for st. judes
@sam_cs_49er
@sam_cs_49er 6 ай бұрын
Can u do this subject (oop) for JavaScript?
@William23-dt1mr
@William23-dt1mr 6 ай бұрын
Please continue the React course bro :(
@Belladonna_khaday
@Belladonna_khaday 4 ай бұрын
Thank you❤❤
@Hasan10-oh7vl
@Hasan10-oh7vl 6 ай бұрын
Loveee ittt !!! Do you need a video editor? I can do a sample video ;)
@lokeshkumaryadav2254
@lokeshkumaryadav2254 6 ай бұрын
Pls make a series on flutter
@osama4y1
@osama4y1 6 ай бұрын
Hello im new how i can start
@ratulmitra347
@ratulmitra347 6 ай бұрын
name = input("enter your name: ") gender = input("enter your gender: ") country = input("enter the country: ") print(f"welcome to {country}, {gender} {name}") I want to put Mr. Or Mrs. Depending on the gender using if else inside the print() function but couldn't able to do it.... Can you please help me??? Thanks
@MAD-SKILLZ
@MAD-SKILLZ 6 ай бұрын
Here's something I worked up for you: name = input('...') gender = input('...') country = input('...') if 'male' in gender: title = 'Mr.' elif 'female' in gender: title = 'Mrs.' else: title = '' print(f'Welcome to {country}, {title} {name}!')
@ratulmitra347
@ratulmitra347 6 ай бұрын
@@MAD-SKILLZ thanks... I did it too.... Actually I wanted to use if else within print function.... Maybe it's not possible... Anyway thanks again
@MAD-SKILLZ
@MAD-SKILLZ 6 ай бұрын
@@ratulmitra347 Actually, it is possible, it just doesn't look very nice: name = input('...') gender = input('...') country = input('...') print(f'Welcome to {country}, {"Mr." if gender == "male" else ("Mrs." if gender == "female" else "")} {name}!') (Also, I made a mistake in my first comment. You should use '==' instead of 'in' because the substring 'male' is also in the string 'female'. Opps haha)
@ratulmitra347
@ratulmitra347 6 ай бұрын
@@MAD-SKILLZ name = input("enter your name: ") gender = input("enter your gender: ") country = input("enter the country: ") if gender=='male': print(f"welcome to {country}, Mr. {name}") else: print(f"welcome to {country}, Mrs. {name}") I did this
@ratulmitra347
@ratulmitra347 6 ай бұрын
@@MAD-SKILLZ yes it doesn't look cool but I didn't know that if else can be used inside print function.... When, a lot of time ago, I used c and c++ I didn't ever use if else inside printf function.... So that is why I wanted to do it... It looked weird but at the same time little bit cool to me.... Thanks for solving it though.... Now I need to understand how it all works
@isdispvp__
@isdispvp__ 6 ай бұрын
first to comment
@MarwaRanya-ek6re
@MarwaRanya-ek6re 6 ай бұрын
Code father
Python Decorators in 15 Minutes
15:14
Kite
Рет қаралды 451 М.
Python INHERITANCE in 6 minutes! 👨‍👦‍👦
6:57
Bro Code
Рет қаралды 9 М.
How Much Tape To Stop A Lamborghini?
00:15
MrBeast
Рет қаралды 210 МЛН
БУ, ИСПУГАЛСЯ?? #shorts
00:22
Паша Осадчий
Рет қаралды 2,9 МЛН
МЕНЯ УКУСИЛ ПАУК #shorts
00:23
Паша Осадчий
Рет қаралды 5 МЛН
Python MAGIC METHODS are easy! 🌟
13:36
Bro Code
Рет қаралды 9 М.
5 Good Python Habits
17:35
Indently
Рет қаралды 622 М.
Learn Python OOP in under 20 Minutes
18:32
Indently
Рет қаралды 107 М.
Let's code a beginner Python BANKING PROGRAM 💰
15:01
Bro Code
Рет қаралды 263 М.
Python *ARGS & **KWARGS are awesome! 📦
14:54
Bro Code
Рет қаралды 84 М.
Python lists, sets, and tuples explained 🍍
15:06
Bro Code
Рет қаралды 314 М.
A simple explanation of super() in Python
15:02
Sebastiaan Mathôt
Рет қаралды 48 М.
Python Data Classes Are AMAZING! Here's Why
16:11
Tech With Tim
Рет қаралды 85 М.
Python Object Oriented Programming (OOP) - For Beginners
53:06
Tech With Tim
Рет қаралды 3,4 МЛН
super/MRO, Python's most misunderstood feature.
21:07
mCoding
Рет қаралды 220 М.
How Much Tape To Stop A Lamborghini?
00:15
MrBeast
Рет қаралды 210 МЛН