Loading…
Loading…
Trainer-curated Q&A from EmergenTeck experts. Updated for 2026 hiring season.
Click any question to reveal the expert answer. Study at your own pace.
Ans: Python is a programming language with objects, modules, threads, exceptions and automatic memory management. The benefits of pythons are that it is simple and easy, portable, extensible, build-in data structure and it is an open source.
Ans: PEP 8 is a coding convention, a set of recommendation, about how to write your Python code more readable.
Ans: Pickle module accepts any Python object and converts it into a string representation and dumps it into a file by using dump function, this process is called pickling. While the process of retrieving original Python objects from the stored string representation is called unpickling.
Ans: Python language is an interpreted language. Python program runs directly from the source code. It converts the source code that is written by the programmer into an intermediate language, which is again translated into machine language that has to be executed.
Ans: Python memory is managed by Python private heap space. All Python objects and data structures are located in a private heap. The programmer does not have an access to this private heap and interpreter takes care of this Python private heap. The allocation of Python heap space for Python objects is done by Python memory manager. The core API gives access to some tools for the programmer to code. Python also have an inbuilt garbage collector, which recycle all the unused memory and frees the memory and makes it available to the heap space.
Ans: PyChecker is a static analysis tool that detects the bugs in Python source code and warns about the style and complexity of the bug. Pylint is another tool that verifies whether the module meets the coding standard.
Ans: A Python decorator is a specific change that we make in Python syntax to alter functions easily.
Ans: The difference between list and tuple is that list is mutable while tuple is not. Tuple can be hashed for e.g as a key for dictionaries.
Ans: Everything in Python is an object and all variables hold references to the objects. The references values are according to the functions; as a result you cannot change the value of the references. However, you can change the objects if it is mutable.
Ans: They are syntax constructions to ease the creation of a Dictionary or List based on existing iterable.
Ans: There are mutable and Immutable types of Pythons built in types Mutable built-in types List Sets Dictionaries Immutable built-in types Strings Tuples Numbers
Ans: In Python, every name introduced has a place where it lives and can be hooked for. This is known as namespace. It is like a box where a variable name is mapped to the object placed. Whenever the variable is searched out, this box will be searched, to get corresponding object.
Ans: It is a single expression anonymous function often used as In-line function.
Ans: A lambda form in python does not have statements as it is used to make new function object and then return them at runtime.
Ans: Pass means, no-operation Python statement, or in other words it is a place holder in compound statement, where there should be a blank left and nothing has to be written there.
Ans: In Python, iterators are used to iterate a group of elements, containers like list.
Ans: A unit testing framework in Python is known as unittest. It supports sharing of setups, automation testing, shutdown code for tests, aggregation of tests into collections etc.
Ans: A mechanism to select a range of items from sequence types like list, tuple, strings etc. is known as slicing.
Ans: The way of implementing iterators are known as generators. It is a normal function except that it yields expression in the function.
Ans: A Python documentation string is known as docstring, it is a way of documenting Python functions, modules and classes.
Ans: To copy an object in Python, you can try copy.copy () or copy.deepcopy() for the general case. You cannot copy all objects but most of them.
Ans: Python sequences can be index in positive and negative numbers. For positive index, 0 is the first index, 1 is the second index and so forth. For negative index, (-1) is the last index and (-2) is the second last index and so forth.
Ans: In order to convert a number into a string, use the inbuilt function str(). If you want a octal or hexadecimal representation, use the inbuilt function oct() or hex().
Ans: Xrange returns the xrange object while range returns the list, and uses the same memory and no matter what the range size is.
Ans: In Python, module is the way to structure program. Each Python program file is a module, which imports other modules like objects and attributes. The folder of Python program is a package of modules. A package can have modules or subfolders.
Ans: Local variables: If a variable is assigned a new value anywhere within the function’s body, it’s assumed to be local. Global variables: Those variables that are only referenced inside a function are implicitly global.
Ans: To share global variables across modules within a single program, create a special module. Import the config module in all modules of your application. The module will be available as a global variable across modules.
Ans: Script file’s mode must be executable and the first line must begin with # ( #!/usr/local/bin/python)
Ans: By using a command os.remove (filename) or os.unlink(filename)
Ans: To generate random numbers in Python, you need to import command as import random random.random() This returns a random floating point number in the range [0,1)
Ans: You can access a module written in Python from C by following method, Module = =PyImport_ImportModule(“”);
Ans: It is a Floor Divisionoperator , which is used for dividing two operands with the result as quotient showing only digits before the decimal point. For instance, 10//5 = 2 and 10.0//5.0 = 2.0.
Ans: Python comprises of a huge standard library for most Internet platforms like Email, HTML, etc. Python does not require explicit memory management as the interpreter itself allocates the memory to new variables and free them automatically Provide easy readability due to use of square brackets Easy-to-learn for beginners Having the built-in data types saves programming time and effort from declaring variables
Ans: The use of the split function in Python is that it breaks a string into shorter strings using the defined separator. It gives a list of all words present in the string.
Ans: Flask is a web micro framework for Python based on “Werkzeug, Jinja 2 and good intentions” BSD licensed. Werkzeug and jingja are two of its dependencies. Flask is part of the micro-framework. Which means it will have little to no dependencies on external libraries. It makes the framework light while there is little dependency to update and less security bugs.
Ans: Flask is a “micro framework” primarily build for a small application with simpler requirements. In flask, you have to use external libraries. Flask is ready to use. Pyramid are build for larger applications. It provides flexibility and lets the developer use the right tools for their project. The developer can choose the database, URL structure, templating style and more. Pyramid is heavy configurable. Like Pyramid, Django can also used for larger applications. It includes an ORM.
Ans: Flask-WTF offers simple integration with WTForms. Features include for Flask WTF are Integration with wtforms Secure form with csrf token Global csrf protection Internationalization integration Recaptcha supporting File upload that works with Flask Uploads
Ans: The common way for the flask script to work is… Either it should be the import path for your application Or the path to a Python file
Ans: A session basically allows you to remember information from one request to another. In a flask, it uses a signed cookie so the user can look at the session contents and modify. The user can modify the session if only it has the secret key Flask.secret_key.
Ans: Basically, Flask is a minimalistic framework which behaves same as MVC framework. So MVC is a perfect fit for Flask, and the pattern for MVC we will consider for the following example from flask import Flaskapp = Flask(_name_) @app.route(“/”) Def hello(): return “Hello World” app.run(debug = True) In this code your, Configuration part will be from flask import Flask app = Flask(_name_) View part will be @app.route(“/”) Def hello(): return “Hello World” While you model or main part will be app.run(debug = True)
Ans: Beginner’s Answer: Python is an interpreted, interactive, objectoriented programming language. Expert Answer: Python is an interpreted language, as opposed to a compiled one, though the distinction can be blurry because of the presence of the bytecode compiler. This means that source files can be run directly without explicitly creating an executable which is then run.
Ans: An interpreted languageis a programming languagefor which most of its implementations execute instructions directly, without previously compiling a program into machinelanguageinstructions. In context of Python, it means that Python program runs directly from the source code.
Ans: Indentation.
Ans: defmy_func(x): returnx**2
Ans: Dynamic. In a statically typed language, the type of variables must be known (and usually declared) at the point at which it is used. Attempting to use it will be an error. In a dynamically typed language, objects still have a type, but it is determined at runtime. You are free to bind names (variables) to different objects with a different type. So long as you only perform operations valid for the type the interpreter doesn’t care what type they actually are.
Ans: Strong. In a weakly typed language a compiler / interpreter will sometimes change the type of a variable. For example, in some languages (like JavaScript) you can add strings to numbers ‘x’ + 3 becomes ‘x3’. This can be a problem because if you have made a mistake in your program, instead of raising an exception execution will continue but your variables now have wrong and unexpected values. In a strongly typed language (like Python) you can’t perform operations inappropriate to the type of the object attempting to add numbers to strings will fail. Problems like these are easier to diagnose because the exception is raised at the point where the error occurs rather than at some other, potentially far removed, place.
Ans: some_variable=u’Thisisateststring’ Or some_variable=u”Thisisateststring”
Ans: Python doesn’t support switchcase statements. You can use ifelse statements for this purpose.
Ans: A lambda statement is used to create new function objects and then return them at runtime. Example: my_func=lambdax:x**2 creates a function called my_func that returns the square of the argument passed.
Ans: If a variable is defined outside function then it is implicitly global. If variable is assigned new value inside the function means it is local. If we want to make it global we need to explicitly define it as global. Variable referenced inside the function are implicit global
Ans: #!/usr/bin/python deffun1(a): print’a:’,a a=33; print’locala:’,a a=100 fun1(a) print’aoutsidefun1:’,a Ans. Output: a:100 locala:33 aoutsidefun1:100
Ans: #!/usr/bin/python deffun2(): globalb print’b:’,b b=33 print’globalb:’,b b=100 fun2() print’boutsidefun2′,b Ans. Output: b:100 globalb:33 boutsidefun2:33
Ans: #!/usr/bin/python deffoo(x,y): globala a=42 x,y=y,x b=33 b=17 c=100 print(a,b,x,y) a,b,x,y=1,15,3,4 foo(17,4) print(a,b,x,y) Ans.Output: 4217417 421534
Ans: #!/usr/bin/python deffoo(x=[]): x.append(1) returnx foo() foo() Output: [1] [1,1]
Ans: By specifying #!/usr/bin/pythonyou specify exactly which interpreter will be used to run the script on a particular system. This is the hardcoded path to the python interpreter for that particular system. The advantage of this line is that you can use a specific python version to run your code.
Ans: list=[‘a’,’b’,’c’,’d’,’e’] printlist[10] Ans. Output: IndexError.Or Error.
Ans: list=[‘a’,’b’,’c’,’d’,’e’] printlist[10:] Ans. Output: [] Theabovecodewilloutput[],andwillnotresultinanIndexError. As one would expect, attempting to access a member of a list using an index that exceeds the number of members results in an IndexError.
Ans: [x**2forxinrange(10)ifx%2==0] Ans. Creates the following list: [0,4,16,36,64]
Ans: Sets and dictionaries support it. However tuples are immutable and have generators but not comprehensions. Set Comprehension: r={xforxinrange(2,101) ifnotany(x%y==0foryinrange(2,x))} Dictionary Comprehension: {i:jfori,jin{1:’a’,2:’b’}.items()} since {1:’a’,2:’b’}.items()returnsalistof2-Tuple.iisthefirstelement oftuplejisthesecond.
Ans: Mutable Types Immutable Types Dictionary number List boolean string tuple
Ans: Generators are functions that return an iterable collection of items, one at a time, in a set manner. Generators, in general, are used to create iterators with a different approach. They employ the use of yield keyword rather than return to return a generator object . Let’s try and build a generator for fibonacci numbers – ## generate fibonacci numbers upto n def fib(n): p, q = 0, 1 while(p 0 x.__next__() # output => 1 x.__next__() # output => 1 x.__next__() # output => 2 x.__next__() # output => 3 x.__next__() # output => 5 x.__next__() # output => 8 x.__next__() # error ## iterating using loop for i in fib(10): print(i) # output => 0 1 1 2 3 5 8
Ans: One of the reasons to use generator is to make the solution clearer for some kind of solutions. The other is to treat results one at a time, avoiding building huge lists of results that you would process separated anyway.
Ans: Use list instead of generator when: 1 You need to access the data multiple times (i.e. cache the results instead of recomputing them) 2 You need random access (or any access other than forward sequential order): 3 You need to join strings (which requires two passes over the data) 4 You are using PyPy which sometimes can’t optimize generator code as much as it can with normal function calls and list manipulations.
Ans: Emacs. Any alternate answer leads to instant disqualification of the applicant
Ans: Iterating over the generator expression or the list comprehension will do the same thing. However, the list comp will create the entire list in memory first while the generator expression will create the items on the fly, so you are able to use it for very large (and also infinite!) sequences.
Ans: Python arrays and list items can be accessed with positive or negative numbers. A negative Index accesses the elements from the end of the list counting backwards. Example: a=[123] printa[-3] printa[-2] Outputs: 1 2
Ans: Range returns a list while xrange returns an xrange object which take the same memory no matter of the range size. In the first case you have all items already generated (this can take a lot of time and memory). In Python 3 however, range is implemented with xrange and you have to explicitly call the list function if you want to convert it to a list.
Ans: Builtin dir() function of Python ,on an instance shows the instance variables as well as the methods and class attributes defined by the instance’s class and all its base classes alphabetically. So by any object as argument to dir() we can find all the methods & attributes of the object’s class
Ans: pass
Ans: First list are mutable while tuples are not, and second tuples can be hashed e.g. to be used as keys for dictionaries. As an example of their usage, tuples are used when the order of the elements in the sequence matters e.g. a geographic coordinates, “list” of points in a path or route, or set of actions that should be executed in specific order. Don’t forget that you can use them a dictionary keys. For everything else use lists
Ans: “Self” is a variable that represents the instance of the object to itself. In most of the object oriented programming languages, this is passed to the methods as a hidden parameter that is defined by an object. But, in python it is passed explicitly. It refers to separate instance of the variable for individual objects. The variables are referred as “self.xxx”.
Ans: Memory management in Python involves a private heap containing all Python objects and data structures. Interpreter takes care of Python heap and the programmer has no access to it. The allocation of heap space for Python objects is done by Python memory manager. The core API of Python provides some tools for the programmer to code reliable and more robust program. Python also has a builtin garbage collector which recycles all the unused memory. The gc module defines functions to enable /disable garbage collector: gc.enable() Enables automatic garbage collection. gc.disable()-Disables automatic garbage collection
Ans: It is used to import a module in a directory, which is called package import.
Ans: try: withopen(‘filename’,’r’)asf: printf.read() exceptIOError: print”Nosuchfileexists”
Ans: We can create a config file and store the entire global variable to be shared across modules in it. By simply importing config, the entire global variable defined will be available for use in other modules. For example I want a, b & c to share between modules. config.py : a=0 b=0 c=0 module1.py: importconfig config.a=1 config.b=2 config.c=3 print”a,b&resp.are:”,config.a,config.b,config.c output of module1.py will be 123
Ans: Yes Medium
Ans: Following is one possible solution there can be other similar ones: import os for dirname,dirnames,filenames in os.walk(‘.’): #printpathtoallsubdirectoriesfirst. forsubdirnameindirnames: printos.path.join(dirname,subdirname) #printpathtoallfilenames. forfilenameinfilenames: printos.path.join(dirname,filename) #Advancedusage: #editingthe’dirnames’listwillstopos.walk()fromrecursing intothere. if’.git’indirnames: #don’tgointoany.gitdirectories. dirnames.remove(‘.git’)
Ans: The easiest way is to use the += operator. If the string is a list of character, join() function can also be used.
Ans: use lower() function. Example: s=’MYSTRING’ prints.lower()
Ans: Similar to the above question. use upper() function instead.
Ans: The easiest way is to use the in operator. >>> ‘abc’ in ‘abcdefg’ True
Ans: There is no simple builtin string function that does what you’re looking for, but you could use the more powerful regular expressions: >>>[m.start()forminre.finditer(‘test’,’testtesttesttest’)] [0,5,10,15]//thesearestartingindicesforthestring
Ans: Python’s GIL is intended to serialize access to interpreter internals from different threads. On multicore systems, it means that multiple threads can’t effectively make use of multiple cores. (If the GIL didn’t lead to this problem, most people wouldn’t care about the GIL it’s only being raised as an issue because of the increasing prevalence of multicore systems.) Note that Python’s GIL is only really an issue for CPython, the reference implementation. Jython and IronPython don’t have a GIL. As a Python developer, you don’t generally come across the GIL unless you’re writing a C extension. C extension writers need to release the GIL when their extensions do blocking I/O, so that other threads in the Python process get a chance to run.
Ans: use the index() function >>>[“foo”,”bar”,”baz”].index(‘bar’) 1 .
Ans: You are looking for the enumerate function. It takes each element in a sequence (like a list) and sticks it’s location right before it. For example: >>>my_list=[‘a’,’b’,’c’] >>>list(enumerate(my_list)) [(0,’a’),(1,’b’),(2,’c’)] Note that enumerate() returns an object to be iterated over, so wrapping it in list() just helps us see what enumerate() produces. An example that directly answers the question is given below my_list=[‘a’,’b’,’c’] fori,charinenumerate(my_list): printi,char The output is: 0a 1b 2c
Ans: In early pythonversions, the sort function implemented a modified version of quicksort. However, it was deemed unstable and as of 2.3 they switched to using an adaptive mergesort algorithm.
Ans: my_list=[(x,y,z)forxinrange(1,30)foryinrange(x,30)forzin range(y,30)ifx**2+y**2==z**2] It creates a list of tuples called my_list, where the first 2 elements are the perpendicular sides of right angle triangle and the third value ‘z’ is the hypotenuse. [(3,4,5),(5,12,13),(6,8,10),(7,24,25),(8,15,17),(9,12,15), (10,24,26),(12,16,20),(15,20,25),(20,21,29)]
Ans: Gather the arguments using the * and ** specifiers in the function’s parameter list. This gives us positional arguments as a tuple and the keyword arguments as a dictionary. Then we can pass these arguments while calling another function by using * and **: deffun1(a,*tup,**keywordArg): … keywordArg[‘width’]=’23.3c’ … Fun2(a,*tup,**keywordArg)
Ans: A higherorder function accepts one or more functions as input and returns a new function. Sometimes it is required to use function as data To make high order function , we need to import functools module The functools.partial() function is used often for high order function.
Ans: The syntax of map is: map(aFunction,aSequence) The first argument is a function to be executed for all the elements of the iterable given as the second argument. If the function given takes in more than 1 arguments, then many iterables are given.
Ans: L=[0,10,20,30,40,50,60,70,80,90] L[::2]
Ans: Yes.
Ans: Objects referenced from the global namespaces of Python modules are not always deallocated when Python exits. This may happen if there are circular references. There are also certain bits of memory that are allocated by the C library that are impossible to free (e.g. a tool like the one Purify will complain about these). Python is, however, aggressive about cleaning up memory on exit and does try to destroy every single object. If you want to force Python to delete certain things on deallocation, you can use the at exit module to register one or more exit functions to handle those deletions.
Ans: Jython.
Ans: Add u before the string. u ‘mystring’
Ans: docstring is the documentation string for a function. It can be accessed by function_name.__doc__
Ans: words=[‘one’,’one’,’two’,’three’,’three’,’two’] A bad solution would be to iterate over the list and checking for copies somehow and then remove them! A very good solution would be to use the set type. In a Python set, duplicates are not allowed. So, list(set(words)) would remove the duplicates.
Ans: withopen(“filename.txt”,”r”)asf1: printlen(f1.readline().rstrip()) rstrip() is an inbuilt function which strips the string from the right end of spaces or tabs (whitespace characters).
Ans: func([1,2,3])#explicitlypassinginalist func() #usingadefaultemptylist deffunc(n=[]): #dosomethingwithn printn This would result in a NameError. The variable n is local to function func and can’t be accessesd outside. So, printing it won’t be possible.
Ans: s = a + ‘[‘ + b + ‘:’ + c + ‘]’ seems like a string is being concatenated. Nothing much can be said without knowing types of variables a, b, c. Also, if all of the a, b, c are not of type string, TypeError would be raised. This is because of the string constants (‘[‘ , ‘]’) used in the statement.
Ans: A Python decorator is a specific change that we make in Python syntax to alter functions easily.
Ans: In Python, every name introduced has a place where it lives and can be hooked for. This is known as namespace. It is like a box where a variable name is mapped to the object placed. Whenever the variable is searched out, this box will be searched, to get corresponding object.
Ans: Python can convert any value to a string by making use of two functions repr() or str(). The str() function returns representations of values which are humanreadable, while repr() generates representations which can be read by the interpreter. repr() returns a machinereadable representation of values, suitable for an exec command. Following code sniipets shows working of repr() & str() : deffun(): y=2333.3 x=str(y) z=repr(y) print”y:”,y print”str(y):”,x print”repr(y):”,z fun() - - - - - output y:2333.3 str(y):2333.3 repr(y):2333.3000000000002
Ans: LIST comprehensions features were introduced in Python version 2.0, it creates a new list based on existing list. It maps a list into another list by applying a function to each of the elements of the existing list. List comprehensions creates lists without using map() , filter() or lambda form.
Ans: There are two ways in which objects can be copied in python. Shallow copy & Deep copy. Shallow copies duplicate as minute as possible whereas Deep copies duplicate everything. If a is object to be copied then … copy.copy(a) returns a shallow copy of a. copy.deepcopy(a) returns a deep copy of a.
Ans: The smtplib module defines an SMTP client session object that can be used to send mail to any Internet machine. A sample email is demonstrated below. import smtplib SERVER = smtplib.SMTP(‘smtp.server.domain’) FROM = sender@mail.com TO = [“user@mail.com”] # must be a list SUBJECT = “Hello!” TEXT = “This message was sent with Python’s smtplib.” # Main message message = “”” From: Lincoln To: CarreerRide user@mail.com Subject: SMTP email msg This is a test email. Acknowledge the email by responding. “”” % (FROM, “, “.join(TO), SUBJECT, TEXT) server = smtplib.SMTP(SERVER) server.sendmail(FROM, TO, message) server.quit()
Ans: c++.
Ans: There are two ways in which Multidimensional list can be created: By direct initializing the list as shown below to create myList below. >>>myList=[[227,122,223],[222,321,192],[21,122,444]] >>>printmyList[0] >>>printmyList[1][2] ____________________ Output [227, 122, 223] 192 The second approach is to create a list of the desired length first and then fill in each element with a newly created lists demonstrated below : >>>list=[0]*3 >>>foriinrange(3): >>>list[i]=[0]*2 >>>foriinrange(3): >>>forjinrange(2): >>>list[i][j]=i+j >>>printlist __________________________ Output [[0,1],[1,2],[2,3]]
Ans: Disadvantages of Python are: Python isn’t the best for memory intensive tasks. Python is interpreted language & is slow compared to C/C++ or Java.
Ans. As python is scripting language forms processing is done by Python. We need to import cgi module to access form fields using FieldStorage class. Every instance of class FieldStorage (for ‘form’) has the following attributes: form.name: The name of the field, if specified. form.filename: If an FTP transaction, the clientside filename. form.value: The value of the field as a string. form.file: file object from which data can be read. form.type: The content type, if applicable. form.type_options: The options of the ‘contenttype’ line of the HTTP request, returned as a dictionary. form.disposition: The field ‘contentdisposition’; None if unspecified. form.disposition_options: The options for ‘contentdisposition’. form.headers: All of the HTTP headers returned as a dictionary. A code snippet of form handling in python: importcgi form=cgi.FieldStorage() ifnot(form.has_key(“name”)andfo
Ans: Python program runs directly from the source code. Each type Python programs are executed code is required. Python converts source code written by the programmer into intermediate language which is again translated it into the native language machine language that is executed. So Python is an Interpreted language.
Ans. _init__ () is a first
LIST vs TUPLES LIST TUPLES Lists are mutable i.e they can be edited. Tuples are immutable (tuples are lists which can’t be edited). Lists are slower than tuples. Tuples are faster than list. Syntax: list_1 = [10, ‘Chelsea’, 20] Syntax: tup_1 = (10, ‘Chelsea’ , 20) 114.What are the key features of Python? Ans: Python is an interpreted language. That means that, unlike languages like C and its variants, Python does not need to be compiled before it is run. Other interpreted languages include PHP and Ruby . Python is dynamically typed , this means that you don’t need to state the types of variables when you declare them or anything like that. You can do things like x=111 and then x="I'm a string" without error Python is well suited to object orientated programming in that it allows the definition of classes along with composition and inheritance. Python does not have access specifiers (like
Ans: To install Python on Windows, follow the below steps: Install python from this link: https://www.python.org/downloads/ After this, install it on your PC. Look for the location where PYTHON has been installed on your PC using the following command on your command prompt: cmd python. Then go to advanced system settings and add a new variable and name it as PYTHON_NAME and paste the copied path. Look for the path variable, select its value and select ‘edit’. Add a semicolon towards the end of the value if it’s not present and then type %PYTHON_HOME% 123. Is indentation required in python? Ans: Indentation is necessary for Python. It specifies a block of code. All code within loops, classes, functions, etc is specified within an indented block. It is usually done using four space characters. If your code is not indented necessarily, it will not execute accurately and will throw errors a
Ans: Modules can be imported using the import keyword. You can import modules in three ways- Example: 123 import array #importing using the original module name import array as arr # importing using an alias name from array import * #imports everything present in the array module 163. Explain Inheritance in Python with an example. Ans: Inheritance allows One class to gain all the members(say attributes and methods) of another class. Inheritance provides code reusability, makes it easier to create and maintain an application. The class from which we are inheriting is called super-class and the class that is inherited is called a derived / child class. They are different types of inheritance supported by Python: Single Inheritance – where a derived class acquires the members of a single super class. Multi-level inheritance – a derived class d1 in inherited from base class base1, and d2 are
Ans: The built-in method which decides the types of the variable at the program runtime is known as type() in Python. When a single argument is passed through it, then it returns given object type. When 3 arguments pass through this, then it returns a new object type.
Ans: Similar to PERL and PHP, Python is processed by the interpreter at runtime. Python supports Object-Oriented style of programming, which encapsulates code within objects. Derived from other languages, such as ABC, C, C++, Modula-3, SmallTalk, Algol-68, Unix shell, and other scripting languages. Python is copyrighted, and its source code is available under the GNU General Public License (GPL). Supports the development of many applications, from text processing to games. Works for scripting, embedded code and compiled the code. Detailed
Ans: Memory is managed by the private heap space. All objects and data structures are located in a private heap, and the programmer has no access to it. Only the interpreter has access. Python memory manager allocates heap space for objects. The programmer is given access to some tools for coding by the core API. The inbuilt garbage collector recycles the unused memory and frees up the memory to make it available for the heap space.
Ans: For performing Static Analysis, PyChecker is a tool that detects the bugs in source code and warns the programmer about the style and complexity. Pylint is another tool that authenticates whether the module meets the coding standard. 181.How Does Python Handle Memory Management? Ans: Python uses private heaps to maintain its memory. So the heap holds all the Python objects and the data structures. This area is only accessible to the Python interpreter; programmers can’t use it. And it’s the Python memory manager that handles the Private heap. It does the required allocation of the memory for Python objects. Python employs a built-in garbage collector, which salvages all the unused memory and offloads it to the heap space. 182.What Are The Principal Differences Between The Lambda And Def? Ans: Lambda Vs. Def. Def can hold multiple expressions while lambda is a uni-expression function
Ans: Any Python file is a module , its name being the file’s base name without the .py extension. import my_module A package is a collection of Python modules: while a module is a single Python file, a package is a directory of Python modules containing an additional init .py file, to distinguish a package from a directory that just happens to contain a bunch of Python scripts. Packages can be nested to any depth, provided that the corresponding directories contain their own init .py file. Packages are modules too. They are just packaged up differently; they are formed by the combination of a directory plus init .py file. They are modules that can contain other modules. from my_package.timing.danger.internets import function_of_love 329. What is GIL? Ans: Python has a construct called the Global Interpreter Lock (GIL). The GIL makes sure that only one of your ‘threads’ can execute at any
EmergenTeck's expert trainers guide you from automation basics to enterprise-grade bot development. Hands-on projects, live sessions, and placement support included.
Preparing for multiple tools? Browse our full library of expert Q&A guides.