xFactorSchool.com
Python
JavaScript
How to Do Examples
C Examples
Python Examples
HTML Examples
Code Examples
C Code Examples
C++ Code Examples
C# Code Examples
Java Code Examples
Python Code Examples
HTML Code Examples
CSS Code Examples
JavaScript Code Examples
Online Compilers
C Compiler
C++ Compiler
C# Compiler
Java Compiler
Python Compiler
HTML Code Editor
CSS Code Editor
JavaScript Compiler
JavaScript Code Editor
Practice how to inherit a class in Python
Python Online Editor
Execute Code
More Python Sample Codes
# Declaring person class class Person: def __init__(self): self.Name = "" self.Age = 0 # Declaring Student class class Student(Person): # Inheriting Person class def __init__(self): super().__init__() self.StudentId = 0 # Create a Student object studentObj = Student() studentObj.Name = "John" studentObj.Age = 15 studentObj.StudentId = 11 print(studentObj.Name + " is " + str(studentObj.Age) + " years old. His student id is " + str(studentObj.StudentId) + ".")