What are the key features of Python?
Python is a object-oriented,open source programming language
It runs on different platforms like Windows, Linux,Macintosh etc.
It is easy to read as it has a clean syntax
It can be integrated with different languages such as Java,C,C++,C#.
What is PEP 8?
It is a set of coding conventions for the Python code and defines things such as method names,variable names,exception names etc.
Explain the ternary operator in Python?
It specifies a boolean expression and returns one of the two values based on the value of the boolean expression
Following is a ternary operator which returns the value y.
num = x if x < y else y
What is the key difference between a list and the tuple?
Bothe list and tuple are containers of items but list is mutable while tuple is immutable
How does Python handle the memory management?
Memory management in Python is handled using Python memory manager.The Python memory manager consists of different components for different aspects of memory maangement such as:
The user has no control over Python heap as it is performed by the the interpreter.
What is the “self” keyword in Python?
Self is a variable used in a class method which refers to the current instance of the class.
In the following example we are setting a variable called num in SimpleClass as 2.
num = 1
What is NumPy?
- NumPy is a package for scientific computing with Python.It has features such as:
- linear algebra, Fourier transform, and random number capabilities
Explain help() and dir() functions in Python?
- help() function provides information related to modules, keywords, attributes, etc.
- dir() returnd a list of attributes of the object.