Posts

Showing posts from February, 2019

Class in Python

Image
   Concept Python is an object oriented programming language. Almost everything in Python is an object, with its properties and methods. A Class is like an object constructor, or a "blueprint" for creating objects. A class is a user-defined blueprint or prototype from which objects are created. Classes provide a means of bundling data and functionality together. Creating a new class creates a new type of object, allowing new instances of that type to be made. Each class instance can have attributes attached to it for maintaining its state. Class instances can also have methods (defined by its class) for modifying its state. Code Example Example 1: class Human:            pass >>> o = Human() >>> type(o) <class '__main__.Human'> Example 2: class Student:     """         Attributes & Methods     """     def __init__(self, x=0, y="name"):           print("Creating Object For You")       

Python Module & Package

Image
  Concept They are simply directories, but with a twist. Each  package  in  Python  is a directory which MUST contain a special file called __init__.py . This file can be empty, and it indicates that the directory it contains is a  Python package , so it can be imported the same way a  module  can be imported. Find Example Visit below Link : Example Quiz Level 1 Quiz Level 2 Request Me