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.
Question:- Which of the following is invalid in terms of Variable Names? Options: _mystr = "Hello World!" __mystr = "Hello World!" __mystr__ = "Hello World!" None of the mentioned
Answer:- Answer: D: None of the mentioned Explanation: All Statements will be executed successfully. However, the code readability will also be reduced.
Question:- In respect to the scope in Python, which of the following statements is/are TRUE? Statement 1: A variable created within a function belongs to the local scope and can be used outside that function. Statement 2: A local scope is referred to the object present through the execution of code since its inception. Statement 3: A local scope is referred to the local object present in the current function. Options: Only Statement 2 Statement 1 and 3 Only Statement 3 All Statements are True
Answer:- Answer: C: Only Statement 3 Explanation: Local scope, also known as function scope, is the block of code or body of any function in Python. This scope consists of the names that we define within the function. These names will only be observable from the function code. It is created at the function call, not at the definition of the function, so that we will have as many distinct local scopes as the calls in function. This is true even when we call the same function more than one time or recursively. Every call will return a new local scope.
Question:- Among the following statements based on the difference between lists and tuples, which one statement is TRUE? Statement 1: List is a sequence data structure, whereas Tuple is not. Statement 2: Lists are immutable; however, Tuples are mutable. Statement 3: Tuple is a sequence data structure, whereas List is not. Statement 4: Tuples are immutable; however, Lists are mutable. Options: Statement 1 Statement 4 Statement 2 Statement 3
Answer:- Answer: B: Statement 4 Explanation: Apart from many similarities, one of the significant differences between the two is that the Lists are mutable, whereas Tuples are immutable. This statement implies that we can modify or change the values of a list; however, we cant alter the values of a Tuple.
Question:- What are Tags?
Answer:- HTML tags are composed of three things: an opening tag, content and ending tag. Some tags are unclosed tags. HTML documents contain two things: - content, and - tags When a web browser reads an HTML document, the browser reads it from top to bottom and left to right. HTML tags are used to create HTML documents and render their properties. Each HTML tags have different properties. Syntax: content Content is placed between tags to display data on the web page.
Question:- What is formatting in HTML?
Answer:- The HTML formatting is a process of format the text for a better look and feel. It uses different tags to make text bold, italicized, underlined.
