Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
112 Cards in this Set
- Front
- Back
and
|
Logical and.
|
|
and
|
Logical and.
|
|
as
|
Part of the with-as statement.
|
|
assert
|
Assert (ensure) that something is true.
|
|
break
|
Stop this loop right now.
|
|
class
|
Define a class.
|
|
continue
|
Don't process more of the loop, do it again.
|
|
def
|
Define a function.
|
|
del
|
Delete from dictionary.
|
|
elif
|
Else if condition.
|
|
else
|
Else condition.
|
|
except
|
If an exception happens, do this.
|
|
exec
|
Run a string as Python.
|
|
finally
|
Exceptions or not, finally do this no matter what.
|
|
for
|
Loop over a collection of things.
|
|
from
|
Importing specific parts of a module.
|
|
global
|
Declare that you want a global variable.
|
|
if
|
If condition.
|
|
import
|
Import a module into this one to use.
|
|
in
|
Part of for-loops. Also a test of X in Y.
|
|
is
|
Like == to test equality.
|
|
lambda
|
Create a short anonymous function.
|
|
not
|
Logical not.
|
|
or
|
Logical or.
|
|
pass
|
This block is empty.
|
|
print
|
Print this string.
|
|
raise
|
Raise an exception when things go wrong.
|
|
return
|
Exit the function with a return value.
|
|
try
|
Try this block, and if exception, go to except.
|
|
while
|
While loop.
|
|
with
|
With an expression as a variable do.
|
|
yield
|
Pause here and return to caller.
|
|
escape |
backslash ( \ ) character is used to escape characters that otherwise have a special meaning, such as newline, backslash itself, or the quote character |
|
%d
|
Decimal integers (not floating point).
|
|
%i
|
Same as %d.
|
|
%o
|
Octal number.
|
|
%u
|
Unsigned decimal.
|
|
%x
|
Hexadecimal lowercase.
|
|
%X
|
Hexadecimal uppercase.
|
|
%e
|
Exponential notation, lowercase 'e'.
|
|
%E
|
Exponential notation, uppercase 'E'.
|
|
%f
|
Floating point real number.
|
|
%F
|
Same as %f.
|
|
%g
|
Either %f or %e, whichever is shorter.
|
|
%G
|
Same as %g but uppercase.
|
|
%c
|
Character format.
|
|
%r
|
Repr format (debugging format).
|
|
%s
|
String format.
|
|
%%
|
A percent sign.
|
|
+
|
Addition
|
|
-
|
Subtraction
|
|
*
|
Multiplication
|
|
**
|
Power of
|
|
/
|
Division
|
|
//
|
Floor division
|
|
%
|
String interpolate or modulus
|
|
< |
Less than
|
|
>
|
Greater than
|
|
<=
|
Less than equal
|
|
>=
|
Greater than equal
|
|
=
|
Equal
|
|
!=
|
Not equal
|
|
<>
|
Not equal
|
|
( )
|
Parenthesis
|
|
[ ]
|
List brackets
|
|
{ }
|
Dict curly braces
|
|
@
|
At (decorators)
|
|
,
|
Comma
|
|
:
|
Colon
|
|
.
|
Dot
|
|
=
|
Assign equal
|
|
;
|
semi-colon
|
|
+= |
Add and assign
|
|
+=
|
Subtract and assign
|
|
*=
|
Multiply and assign
|
|
/=
|
Divide and assign
|
|
//=
|
Floor divide and assign
|
|
%=
|
Modulus assign
|
|
**=
|
Power assign
|
|
What is Python? |
an open source, interpreted, object oriented programming language |
|
What is PEP 8 |
coding convention to make code more readable |
|
What is pickling/unpickling? |
A way to serialize and de-serialize a Python object structure for writing to a file The character stream contains all information necessary to reconstruct the object in another script. |
|
How is memory managed in Python? |
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. |
|
What is PyChecker? |
A static analysis tool that detects bugs and warns about style and complexity of the bug. |
|
What is Pylint? |
A tool that verifies whether the module meets coding standard. |
|
What are Python decorators? |
A specific change made in Python syntax to alter functions easily. |
|
What is the difference between a list and a tuple? |
List is mutable while not. Tuples can be hashed for e.g. as a key for dictionaries. |
|
How are arguments passed by value or by reference? |
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. |
|
What built-in type does python provide? |
Mutable types: list, sets, dictionaries Immutable types: strings, tuples, numbers |
|
What is namespace 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. |
|
What is a lambda function? |
A way to create small anonymous functions (without a name). |
|
Why do lambda forms not have statements? |
They are used to make new function objects and return at runtime. |
|
What is a pass? |
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. |
|
What are iterators? |
iterators are used to iterate a group of elements, containers like list. |
|
What is unittest? |
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. |
|
What is slicing? |
A mechanism to select a range of items from sequence types like list, tuple, strings etc. is known as slicing. |
|
What are generators? |
The way of implementing iterators are known as generators. It is a normal function except that it yields expression in the function. |
|
What is docstring? |
documentation string is known as docstring, it is a way of documenting Python functions, modules and classes. |
|
How can you copy an object in Python? |
copy.copy() or copy.deepcopy() |
|
What is negative index in Python |
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. |
|
How can you convert a number to a string? |
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(). |
|
What is the difference between Xrange and range? |
Xrange returns the xrange object while range returns the list, and uses the same memory and no matter what the range size is. |
|
What is module and package in Python? |
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. |
|
Mention what are the rules for local and global variables in Python? |
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. |
|
How can you share global variables across modules? |
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. |
|
Explain how to delete a file in Python? |
By using a command os.remove (filename) or os.unlink(filename) |
|
Explain how can you generate random numbers in Python? |
To generate random numbers in Python, you need to import command asimport randomrandom.random()This returns a random floating point number in the range [0,1) |
|
Explain how can you access a module written in Python from C? |
You can access a module written in Python from C by following method,Module = =PyImport_ImportModule(“”); |
|
Mention the use of // operator in Python? |
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. |
|
Mention five benefits of using Python? |
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 automaticallyProvide easy readability due to use of square bracketsEasy-to-learn for beginnersHaving the built-in data types saves programming time and effort from declaring variables |
|
Mention the use of the split function in Python? |
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. |
|
Mention what is the difference between Django, Pyramid, and Flask? |
Flask is a “microframework” 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. |