NLP Python Answer Finals
NLP Python Answer Finals
functions.
String store characters and have many built-in convenience methods that let you
modify their content strings are immutable, meaning they cannot be changed in
place.
Variables are assigned values using the = operator, which is not to be confused
with the == sign used for testing equality, a variable can hold almost any type of
value such as lists, dictionaries, functions.
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.
Map function executes the function given as the first argument on 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.
strip() in-built function of Python is used to remove all the leading and trailing
spaces from a string.
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.
A tuple is another sequence data type that is similar to the list A tuple consists
of a number of values separated by commas Unlike lists, however, tuples are
enclosed within parentheses.
Dictionaries are kind of hash table type They work like associative arrays or
hashes found in Perl and consist of key-value pairs a dictionary key can be almost
any Python type, but are usually numbers or strings Values, on the other hand, can
be any arbitrary python object.
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.
Unpickling process of retrieving original Python objects from the stored string
representation is called unpickling.
Iterators are used for iterating a group of elements, containers like list.
Slicing is a mechanism that helps you in selecting a range of items from sequence
types such as tuple, string, list, etc.
You can delete a file with the help of command (os.remove(filename)) or (os.unlink
(filename)).
Split function in Python helps in breaking a string into shorter strings by using
the defined separator It provides a list of the words contained in the string.
Python memory is managed by Python private heap space All Python objects and data
structures are located in a private heap.
Flask is a web micro framework for Python based on “Werkzeug, Jinja2 and good
intentions” BSD license Werkzeug and Jinja2 are two of its dependencies This means
it will have little to no dependencies on external libraries.
Help function is used to display the documentation string and also facilitates you
to see the help related to modules, keywords, attributes, etc.
We use *args when we aren’t sure how many arguments are going to be passed to a
function, or if we want to pass a stored list or tuple of arguments to a function.
**kwargs is used when we don’t know how many keyword arguments will be passed to a
function, or it can be used to pass the values of a dictionary as keyword
arguments.
Django provides session that lets you 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.
Operator evaluates to true if the variables on either side of the operator point to
the same object and false otherwise x is y, here is results in 1 if id(x) equals
id(y).
Break terminates the loop statement and transfers execution to the statement
immediately following the loop.
Continue auses the loop to skip the remainder of its body and immediately retest
its condition prior to reiterating.
Sqlite3 is the standard library for python for database.
In python we can use import socket a standard library for socket programming in
python for client server interaction.
Yes python can be used for mobile app development using module kivy.
Shallow copy is used when a new instance type gets created and it keeps the values
that are copied in the new instance and Deep copy is used to store the values that
are already copied Deep copy doesn’t copy the reference pointers to the objects.
Random module is the standard module that is used to generate the random number.
In python generally “with” statement is used to open a file, process the data
present in the file, and also to close the file without calling a close() method
“with” statement makes the exception handling simpler by providing cleanup
activities.
Python does not provide interfaces like in Java Abstract Base Class (ABC) and its
feature are provided by the Python’s “abc” module.
Both append() and extend() methods are the methods of list These methods a regex
used to add the elements at the end of the list.
In python (.py) files are Python source files (.pyc) files are the compiled
bvtecode files that is generated by the Python compiler.
In python try, except and finally blocks are used in Python error handling.
Functions in python are defined using the def statement An example might be def
foo(bar):.
Class are created using the class statement An example might be class
abc(parameter):.
Local namespaces are created within a function when that function is called Global
name spaces are created when the program starts.
The break statement stops execution of the current loop and transfers control to
the next block The continue statement ends the current block’s execution and jumps
to the next iteration of the loop.
Pandas is the data filtering module in python used for data preprocessing.
Pythonpath has a role similar to PATH PYTHONPATH variable tells the Python
interpreter where to locate the module files imported into a program PYTHONPATH
should include the Python source library directory.
KeyboardInterrupt is raised when the user hits interrupt key (Ctrl+c or delete).
RuntimeError is raised when an error does not fall under any other category.
ValueError is raised when a function gets argument of correct type but improper
value.
Exceptions which forces your program to output an error when something in it goes
wrong.
Lists is data type that holds an ordered collection of values, which can be of any
type and they are ordered mutable data type unlike tuples, lists can be modified
in-place.
While loop permits code to execute repeatedly until a certain condition is met.
Assert is used during debugging to check for conditions that ought to apply
Continue used to skip the current block, and return to the "for" or "while"
statement
distutils package included in the Python Standard Library for installing, building
and distributing python code.
Easy Install is a python module (easy_install) bundled with setuptools that lets
you automatically download, build, install, and manage Python packages.
Exceptions means of breaking out of the normal flow of control of a code block in
order to handle errors or other exceptional conditions
filter (function, sequence) returns a sequence consisting of those items from the
sequence for which function(item) is true
for iterates over an iterable object, capturing each element to a local variable
for use by the attached block
garbage collection i the process of freeing memory when it is not used anymore.
high level language is designed to be easy for humans to read and write.
import is used to import modules whose functions or variables can be used in the
current program.
interactive mode is when commands are read from a tty, the interpreter is said to
be in interactive mode.
map (function, iterable, ...) apply function to every item of iterable and return a
list of the results.
method is like a function, but it runs "on" an object.
module is the basic unit of code reusability in python,a block of code imported by
some other code.
object is any data with state (attributes or value) and defined behavior (methods).
Pythonic is an idea or piece of code which closely follows the most common idioms
of the python language, rather than implementing code using concepts common to
other languages.
strings can include numbers, letters, and various symbols and be enclosed by either
double or single quotes, although single quotes are more commonly used.
try allows exceptions raised in its attached code block to be caught and handled by
except clauses.
Zen of Python is When you type "import this", Python’s philosophy is printed out.
asynchronous iterable is an object, that can be used in an async for statement Must
return an asynchronous iterator from its __aiter__() method introduced by PEP 492.
waitable is an object that can be used in an await expression Can be a coroutine or
an object with an __await__() method
BDFL Benevolent Dictator For Life, [a.k.a.] Guido van Rossum, Python’s creator.
binary file is a file object able to read and write bytes-like objects Examples of
binary files are files opened in binary mode ('rb', 'wb' or 'rb+'),
[sys.stdin.buffer], [sys.stdout.buffer], and instances of [io.BytesIO] and
[gzip.GzipFile].
EAFP Easier to ask for forgiveness than permission. This common Python coding style
assumes the existence of valid keys or attributes and catches exceptions if the
assumption proves false.
GIL global interpreter lock is the mechanism used by the CPython interpreter to
assure that only one thread executes Python bytecode at a time.
hash-based pyc is a bytecode cache file that uses the hash rather than the last-
modified time of the corresponding source file to determine its validity.
Hashability makes an object usable as a dictionary key and a set member, because
these data structures use the hash value internally.
key function or collation function is a callable that returns a value used for
sorting or ordering For example, [locale.strxfrm()] is used to produce a sort key
that is aware of locale specific sort conventions.
LBYL Look before you leap This coding style explicitly tests for pre-conditions
before making calls or lookups This style contrasts with the EAFP approach and is
characterized by the presence of many if statements.
loader is an object that loads a module It must define a method named load_module()
A loader is typically returned by a finder.
mapping is a container object that supports arbitrary key lookups and implements
the methods specified in the Mapping or MutableMapping abstract base classes.
metaclass is the class of a class, Class definitions create a class name, a class
dictionary, and a list of base classes.
Method Resolution Order is the order in which base classes are searched for a
member during lookup.
new-style class is old name for the flavor of classes now used for all class
objects.
path entry is a single location on the import path which the path based finder
consults to find modules for importing.
path entry finder a finder returned by a callable on sys.path_hooks which knows how
to locate modules given a path entry.
path entry hook is a callable on the [sys.path_hook] list which returns a path
entry finder if it knows how to find modules on a specific path entry.
path based finder is one of the default meta path finders which searches an import
path for modules.
Provisional API is one which has been deliberately excluded from the standard
library’s backwards compatibility guarantees.
type alias is a synonym for a type, created by assigning the type to an identifier,
Type aliases are useful for simplifying type hints.
type hint is an annotation that specifies the expected type for a variable, a class
attribute, or a function parameter or return value.