Teachnique
      CourseRoadmaps
      Login

      OverviewCommentsUser InputNumbersBooleansHistoryHello World ProgramEnvironment SetupSyntaxVariablesData TypesType CastingUnicode SystemLiteralsOperators

      Control FlowBreak StatementContinue StatementPass StatementNested LoopsDecision MakingIf StatementIf-else StatementNested IF StatementMatch-Case StatementLoopsFor LoopsFor-else LoopsWhile Loops

      FunctionsBuilt-in FunctionsDefault ArgumentsKeyword ArgumentsKeyword-Only ArgumentsPositional ArgumentsPositional-Only ArgumentsArbitrary ArgumentsVariable ScopeFunction AnnotationsModules

      StringSlicing StringsModify StringsString ConcatenationString FormattingEscape CharactersString MethodsString Exercises

      ListsList ExercisesAccess List ItemsChange List ItemsAdd List ItemsRemove List ItemsLoop ListsList ComprehensionSort ListsCopy ListsJoin ListsList Methods

      TuplesAccess Tuple ItemsUpdate TuplesUnpack Tuple ItemsLoop TuplesJoin TuplesTuple MethodsTuple Exercises

      SetsAccess Set ItemsAdd Set ItemsRemove Set ItemsLoop SetsJoin SetsCopy SetsSet OperatorsSet MethodsSet Exercises

      DictionariesDictionary ExercisesAccess Dictionary ItemsChange Dictionary ItemsAdd Dictionary ItemsRemove Dictionary ItemsDictionary View ObjectsLoop DictionariesCopy DictionariesNested DictionariesDictionary Methods

      ArraysAccess Array ItemsAdd Array ItemsRemove Array ItemsLoop ArraysCopy ArraysReverse ArraysSort ArraysJoin ArraysArray MethodsArray Exercises

      File HandlingWrite to FileRead FilesRenaming and Deleting FilesDirectoriesFile Methods

      OOP ConceptsDynamic BindingDynamic TypingAbstractionObject and ClassesEncapsulationInterfacesPackagesInner ClassesAnonymous Class and ObjectsSingleton ClassWrapper ClassesEnumsReflectionClass AttributesClass MethodsStatic MethodsConstructorsAccess ModifiersInheritancePolymorphismMethod OverridingMethod Overloading

      Feedback

      Submit request if you have any questions.

      Course
      Object and Classes

      Python Tutorial

      This Python tutorial has been written for the beginners to help them understand the basic to advanced concepts of Python Programming Language. After completing this tutorial, you will find yourself at a great level of expertise in Python, from where you can take yourself to the next levels to become a world class Software Engineer.

      Object and Classes

      Python is a highly object-oriented language. In Python, each and every element in a Python program is an object of one or the other class. A number, string, list, dictionary etc. used in a program they are objects of corresponding built-in classes.

      Example

      num=20
      print (type(num))
      num1=55.50
      print (type(num1))
      s="TutorialsPoint"
      print (type(s))
      dct={'a':1,'b':2,'c':3}
      print (type(dct))
      def SayHello():
      print ("Hello World")
      return
      print (type(SayHello))
      When you execute this code, it will produce the following output
      <class 'int'>
      <class 'float'>
      <class 'str'>
      <class 'dict'>
      <class 'function'>
      In Python, the Object class is the base or parent class for all the classes, built-in as well as user defined.
      The class keyword is used to define a new class. The name of the class immediately follows the keyword class followed by a colon as follows
      class ClassName:
      'Optional class documentation string'
      class_suite
      • The class has a documentation string, which can be accessed via ClassName.__doc__.
      • The class_suite consists of all the component statements defining class members, data attributes and functions.

      Example

      class Employee(object):
      'Common base class for all employees'
      pass
      Any class in Python is a subclass of object class, hence object is written in parentheses. However, later versions of Python don't require object to be put in parentheses.
      class Employee:
      'Common base class for all employees'
      pass
      To define an object of this class, use the following syntax
      e1 = Employee()

      Practice with Online Editor

      Note: This Python online Editor is a Python interpreter written in Rust, RustPython may not fully support all Python standard libraries and third-party libraries yet.
      Remember to save code(Ctrl + S Or Command + S) before run it.