In: Computer Science
Can you please post the most/main important terminologies for Python coding and explain what they mean (e.g. Class - xyz, function - xyz, conductor - xyz, method - xyz, instance variable - xyz, variable - xyz) (Feel free to add anything I may have missed or that you think is also important)?
(NOTE - If you need more information, let me know in the comment box. I have included the basics as mentioned)
PYTHON
It is a high level and general purpose programming language created by Guido van Rossum.
Python is dynamically typed and garbage-collected. It supports multiple programming paradigms including structured, object oriented and functional programming.
IDLE
IDLE is short for Integrated Development Environment for Python. It is the editor and interpreter used for building and executing Python programs.
Python uses whitespace indentation , rather than curly brackets or keywords, to delimit blocks. An increase in indentation comes after certain statements; a decrease in indentation signifies the end of the current block. This feature is sometimes termed the off-side rule, which some other languages share, but in most languages indentation doesn't have any semantic meaning.
Classes and 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.
Some important attributes :
An object is nothing but an instance of a class. It is a real entity.
Functions
In Python, a function is a group of related statements that performs a specific task.Functions help break our program into smaller and modular chunks. As our program grows larger and larger, functions make it more organized and manageable.Furthermore, it avoids repetition and makes the code reusable.
def
that marks the start of the function
header.Constructors
Constructors are generally used for instantiating an object.The task of constructors is to initialize(assign values) to the data members of the class when an object of class is created.In Python the __init__() method is called the constructor and is always called when an object is created.
Syntax :
def __init__(self): # body of the constructor
Methods
Syntax :
class class name
def method name () :
#method body
Class variables and Instance variables
Class Variables — Declared inside the class definition (but outside any of the instance methods). They are not tied to any particular object of the class, hence shared across all the objects of the class. Modifying a class variable affects all objects instance at the same time.
Instance
Variable — Declared inside the constructor method of class
(the __init__
method). They are tied to the particular
object instance of the class, hence the contents of an instance
variable are completely independent from one object instance to the
other.
Example :
class Car :
wheels =4 #class variable
def __init__(self, name) :
self.name = name #instance variable
Libraries
Python's large standard library, commonly cited as one of its greatest strengths, provides tools suited to many tasks. For Internet-facing applications, many standard formats and protocols such as MIME and HTTP are supported. It includes modules for creating graphical user interfaces, connecting to relational databases, generating pseudorandom numbers, arithmetic with arbitrary-precision decimals,manipulating regular expressions, and unit testing.