/ Published in: Python
This simple example will show you how to inherit a class from a parent class. I have to apologise for some grammar mistakes that I've probably put in the comments, but English is not my native language.
If you execute this code, the output will be:
Here comes Lois Lane
Here comes Jimmy Olsen
Here comes Clark Kent
...but his secret identity is 'Superman' and he's a super-hero!
--> Let's see what a man can do:
Jimmy Olsen walks
Lois Lane says: 'Oh no, we're in danger!'
--> Let's see what a superman can do:
Clark Kent walks
Clark Kent says: 'This is a job for SUPERMAN!'
Superman run at the speed of light
Superman fly up in the sky
Superman uses his x-ray vision
If you execute this code, the output will be:
Here comes Lois Lane
Here comes Jimmy Olsen
Here comes Clark Kent
...but his secret identity is 'Superman' and he's a super-hero!
--> Let's see what a man can do:
Jimmy Olsen walks
Lois Lane says: 'Oh no, we're in danger!'
--> Let's see what a superman can do:
Clark Kent walks
Clark Kent says: 'This is a job for SUPERMAN!'
Superman run at the speed of light
Superman fly up in the sky
Superman uses his x-ray vision