Python is a high-level, general-purpose, object-oriented programming language that can run equally on all platforms like Windows, Macintosh, Linux, etc. It is easy to learn and provides high readability for content browsing.
- High readability
- High-level language
- Easy to learn
Below are the applications that can be developed using Python:
- Web development
- Audio or video-based applications
- Image application
- GUI based desktop applications
text = "PYTHON LANGUAGE" print text
- Single line string
- Multiline string
- Single line comment
- Multiple line comment
Guido van Rossum is the developer of Python.
A dictionary is a collection of key-value pairs. We can retrieve the values using the square bracket.
Please click Like if you loved this article?
A tuple is a collection of data that cannot be edited. The values are separated by a comma and enclosed within a square bracket.
x=y=z=100 print x print y print z
- Literal collections
The capitalize() function capitalizes the first character in the string.
We can copy an object using the copy() method or deepcopy() method.
The docstring stands for documentation string which is the way to document function, modules, and classes.
- in operator
- not in operator
PEP stands for Python Enhancement Proposal. It is a set of rules that denotes the code format for Python for better readability which means it provides stict guidelines that we must follow while writing python code.
Python manages memory using the memory manager that stores objects in a private heap space that is inaccessible to the developer. It is a dedicated memory for all Python objects . We can use the core Python API functions to work on these private memory spaces. It also has an in-built garbage collector that reuses the unused heap memory space.
A namespace is a mechanism that avoids naming conflict in a code and ensures that we use only unique names. There are different types of namespaces like local namespace, global namespace and built-in namespace.
PYTHONPATH is an environment variable that it uses to set additional directories to load specific modules and packages. This is useful when we do not need it in default global location. The interpreter uses the PYTHONPATH to load the required modules.
_init_ is a special type of constructor or method that is called automatically whenever we create a new object or instance. This is mainly to differentiate between class and local variables.
The main difference between list and tuples is list elements can be changed or updated and are enclosed within paranthesis () while tuples elements cannot be changed and are enclosed within the square brackets.
Continue: It terminates the current iteration by skipping the remaining code and continues with the next iteration.
break: It terminates the loop and passes the control to the statement after the loop
pass: It is just an empty space that is similar to semicolon ;
In python, self is an object of a class that we use as the first parameter in the init method and denotes the new object. In methods, it refers to the object that calls the method.
Both range and xrange are similar in functionality where it generates integer numbers. The main difference is that the range returns Python list while the range returns an xrange object. Also, xrange generates a dynamic list unlike range which generates a static list. However, xrange support has been deprecated from Python3.x
Please click Like if you loved this article?
Generators are functions that returns a set of items through which we can iterate.
Lambda is an anonymous function that accepts multiple arguments or parameters but can contain only 1 statement. It does not allow block of statements and does not return any value.
We can use the whitespace and trailing space using the built-in strip() method.
Python decorator is a function that adds extra functionality or modifies the behavior of the existing function without affecting or changing the function structure.
The process of converting the Python object to string representation is pickling while the process of retrieving the python object from the string is unpickling.
The help() function displays the help content related to keywords, modules, attributes and documentation string.
The dir() function displays the defined symbols.
Output of val[-3] returns 7 which means the 3rd element from the right
It reverses the order of elements in an array without affecting the original array.
Yes Python supports multiple inheritance
The source code file represents .py and the byte code file represents the .pyc file. After compiling the source code, it generates the byte code file (.pyc file).
*args denotes the number of arguments or variables that we can pass to a function definition.
**kwargs represents the number of keywords that we can pass to a function definition.