Question:- What is lambda function in Python?
Answer:- The anonymous function in python is a function that is defined without a name. The normal functions are defined using a keyword "def", whereas, the anonymous functions are defined using the lambda function. The anonymous functions are also called as lambda functions.
Question:- Why do lambda forms in Python not have the statements?
Answer:- Lambda forms in Python does not have the statement because it is used to make the new function object and return them in runtime.
Question:- What are functions in Python?
Answer:- A function is a block of code which is executed only when it is called. To define a Python function, the def keyword is used.
Question:- What is __init__?
Answer:- The __init__ is a method or constructor in Python. This method is automatically called to allocate memory when a new object/ instance of a class is created. All classes have the __init__ method.
Question:- What is PYTHONPATH?
Answer:- PYTHONPATH is an environment variable which is used when a module is imported. Whenever a module is imported, PYTHONPATH is also looked up to check for the presence of the imported modules in various directories. The interpreter uses it to determine which module to load.
Question:- What are python modules? Name some commonly used built-in modules in Python?
Answer:- Python modules are files containing Python code. This code can either be functions classes or variables. A Python module is a .py file containing executable code. Some of the commonly used built-in modules are: - os - sys - math - random - data time - JSON
Question:- What is the difference between range & xrange?
Answer:- For the most part, xrange and range are the exact same in terms of functionality. They both provide a way to generate a list of integers for you to use, however you please. The only difference is that range returns a Python list object and x range returns an xrange object. This means that xrange doesnt actually generate a static list at run-time like range does. It creates the values as you need them with a special technique called yielding. This technique is used with a type of object known as generators. That means that if you have a really gigantic range youd like to generate a list for, say one billion, xrange is the function to use. This is especially true if you have a really memory sensitive system such as a cell phone that you are working with, as range will use as much memory as it can to create your array of integers, which can result in a Memory Error and crash your program. Its a memory hungry beast.
Question:- What advantages do NumPy arrays offer over (nested) Python lists?
Answer:- - Pythons lists are efficient general-purpose containers. They support (fairly) efficient insertion, deletion, appending, and concatenation, and Pythons list comprehensions make them easy to construct and manipulate. - They have certain limitations: they dont support "vectorized" operations like elementwise addition and multiplication, and the fact that they can contain objects of differing types mean that Python must store type information for every element, and must execute type dispatching code when operating on each element. - NumPy is not just more efficient; it is also more convenient. We get a lot of vector and matrix operations for free, which sometimes allow one to avoid unnecessary work. And they are also efficiently implemented. - NumPy array is faster and we get a lot built in with NumPy, FFTs, convolutions, fast searching, basic statistics, linear algebra, histograms, etc.
Question:- Mention what the Django templates consist of.
Answer:- The template is a simple text file. It can create any text-based format like XML, CSV, HTML, etc. A template contains variables that get replaced with values when the template is evaluated and tags (% tag %) that control the logic of the template.
Question:- Explain the use of session in Django framework?
Answer:- Django provides a session that lets the user store and retrieve data on a per-site-visitor basis. Django abstracts the process of sending and receiving cookies, by placing a session ID cookie on the client side, and storing all the related data on the server side.
Question:- Which of the following statements is/are TRUE in respect of the Python programming language? Statement 1: Python is an interpreted, high-level, general-purpose programming language. Statement 2: Python provides high-level data structures along with dynamic binding and typing for Rapid Application Development and deployment. Statement 3: Python is a Statically typed Programming language. Options: Only Statement 1 Statement 1 and 2 Statement 1 and 3 All Statements are Correct
Answer:- Answer: B: Statement 1 and 2 Explanation: Python is an interpreted, high-level, general-purpose programming language. Being an interpreted language, it executes every block of code line by line, and thus type-checking is done while executing the code. Hence, it is a dynamically typed language. Moreover, Python offers high-level data structures, together with dynamic binding and typing, allows a large community of developers for Rapid Application Development and Deployment.
Question:- What is the full form of PEP? Options: Python Enhancement Proposal Python Enchantment Proposal Programming Enhancement Proposition Python Enrichment Program
Answer:- Answer: A: Python Enhancement Proposal Explanation: A PEP, also known as Python Enhancement Proposal, is an official design document offering information to the community of Python developers or depicting a new feature for Python or its methods.
Question:- Which of the following statements is/are NOT correct regarding Memory Management in Python? Statement 1: Python Memory Manager handles the management regarding memory in Python Statement 2: Python uses CMS (Concurrent Mark Sweep) approach as its Garbage Collection technique. Statement 3: Python offers a core garbage collection to recycle the vacant memory for the private heap space. Options: Only Statement 3 Statement 1 and 3 Statement 2 and 3 Only Statement 2
Answer:- Answer: D: Only Statement 2 Explanation: Python employs the Reference Counting algorithm as its Garbage Collection technique. This technique is highly efficient and straightforward; however, it cant detect the reference cycle. Hence, Python has an additional algorithm known as Generational Cyclic (GC), which only deals with the reference cycle.
Question:- Which of the following statements is/are NOT correct in respect to Python namespaces? Statement 1: Python implements the namespace in the form of Array. Statement 2: Python namespaces are classified into three types - local, global and built-in. Statement 3: A Python namespace ensures that the names of the objects in a program are unique and can be utilized, deprived of any inconsistency. Options: Only Statement 1 Only Statement 3 Statement 1 and 2 Statement 1 and 3
Answer:- Answer: A: Only Statement 1 Explanation: The namespaces in Python are implemented in the form of Dictionaries where key denotes the name, mapped to a corresponding value denoting the object.
