PITCH DECK
Certificación
Python
TABLE OF CONTENTS
01. 02. 03. 04.
Computer Data Collections –
Control Flow – Functions and
Programming and Tuples,
Conditional Blocks Exceptions
Python Dictionaries, Lists,
and Loops
Fundamentals and Strings
FUNCTIONS
1. A function is a named, separate part of the code that can be activated on
demand. A function can perform an action, or return a result, or both.
2. The simplest function, which does nothing and returns no result, can be
defined in the following way:
def name_function():
instructions
3. Activating a function is done by the function invocation (function call). The
lazy() function defined above can be invoked by the following clause:
name_function()
4. Function definition must precede its invocation. Breaking this rule raises
the NameError exception.
5. A function can be equipped with an arbitrary number of parameters. The
parameters behave like variables known inside the function only, and their
values are set during the invocation. The invocation must provide as many
arguments as needed to initialize all parameters. Breaking this rule results
in raising the TypeError exception.
6. If a function is supposed to evaluate a result, it must perform the return
expression instruction, which immediately terminates function execution and
causes the function to return the expression value to the invoker. If the
function does not execute the instruction, or utilizes return without an
expression, the None value is returned implicitly. For example, the following
snippet prints True None to the screen:
def function(parameter):
if parameter == False:
return True
print(function(False))
print(function(True))
7. A function definition can declare default values for some or all of its
parameters. When the invocation does not provide arguments for these
parameters, the default values are taken into consideration.
For example, the following snippet prints True False to the screen:
def function(parameter = False):
return parameter
print(function(True), function())
8. The positional parameter passing technique is a technique based on the
assumption that the arguments are associated with the parameters based upon their
position (i.e. the first argument value goes to the first parameter, and so on) For
example, the following snippet outputs 1 2 3 to the screen:
def function(a, b, c):
print(a, b, c)
function(1, 2, 3)
9. The keyword parameter passing technique is a technique based on the
assumption that the arguments are associated with the parameters based upon the
parameter's names, which must be explicitly specified during the invocation. For
example, the following snippet outputs 1 2 3 to the screen:
def function(a, b, c):
print(a, b, c)
function(c=3, a=1, b=2)
10. A function definition can declare default values for some or all of its parameters.
When the invocation does not provide arguments for these parameters, the default
values are taken into consideration.
For example, the following snippet prints 1 2 3 to the screen:
def function(a, b, c):
print(a, b, c)
function(1, c=3, b=2)
11. Note that the following invocation is incorrect and will raise the TypeError
exception, because the a parameter is set twice (once with the positional passing and
once with the keyword passing) while the c parameter is not set at all.
function(1, a=1, b=2)
SCOPE
12. A scope is the part of the code where a certain name is properly
recognizable.
13. A variable existing outside a function has a scope which includes the
function's bodies.
14. A variable defined inside the function has a scope inside the function's
body only.
Recursion
18. Recursion is a programming technique in which the function invokes
itself to perform a complex task. For example, the following snippet contains a
function that evaluates the factorial of its argument and prints 120 to the
screen:
def factorial(n):
if n < 2:
return n
else:
return n * factorial(n - 1)
print(factorial(5))
Exceptions
1. An exception is an event caused by an execution error which can induce
program termination if not properly handled by the programmer. The situation
in which the exception is created and propagated is called raising the
exception.
2. The programmer should allow the exceptions to occur and handle them
properly instead of persistently avoiding problems and protecting the code
from all possible errors with all their might.
3. To control exceptions and to handle them, Python provides a dedicated
construction consisting of the “try” and “except” branches.
4. The try block encloses a part of the code that may cause an exception and when it
happens, the execution of the block is terminated and the control jumps into the
except block, which is dedicated to recognizing the problem and handling it. For
example, the following snippet prints PROCEEDING even though the code provokes
division by zero:
try:
x=1/0
except:
x = None
print('PROCEEDING')
ZeroDivisionError: raised by a division in which the divider is zero or is indistinguishable from
zero (/, //, and %)
ValueError: raised by the use of values that are inappropriate in the current context, for
example, when a function receives an argument of a proper type, but its value is
unacceptable, for example, int('')
TypeError: raised by attempts to apply data of a type which cannot be accepted in the current
context, for example, int(None)
AttributeError: raised – among other occasions – when the code tries to activate a method
that doesn't exist in a certain item, for example, the_list.apend() (note the typo!)
SyntaxError: raised when the control reaches a line of code that violates Python's grammar,
and which has remained undetected until now;
NameError: raised when the code attempts to make use of a non-existent (not previously
defined) item, for example, a variable or a function.
6. When more than one exception is expected inside the try block and these different
exceptions require different handling, another syntax is used where there is more than
one named except branch. The unnamed (anonymous) except branch is the default
one, and is responsible for servicing these exceptions which still need to be handled.
try:
print(1 / int(input("Enter a number: ")))
except ValueError:
print('NAN')
except ZeroDivisionError:
print('ZERO')
else:
print('PAS')
Debugging
10. An error existing in the code is commonly called a bug.
11. The process by which bugs are detected and removed from the code is
called debugging.
12. The tool which allows the programmer to run the code in a fully controllable
environment is called a debugger.
13. The 'print debugging' technique is a trivial debugging technique in which
the programmer adds some print() function invocations which help to trace
execution paths and output the values of selected critical variables.
14. The process in which the code is probed to ensure that it will behave correctly in a
production environment is called testing. The testing should prove that all execution
paths have been executed and caused no errors.
15. The programming technique in which the tests and test data are created before the
code is written or created in parallel with the code is called unit testing. It is assumed
that every code amendment (even the most trivial) is followed by the execution of all
previously defined tests.
80% Resultados Examen de
Recolección
Inducción Curso Practice Test de
y vouchers Certificación
Certificados
Google
ZOOM
Form WhatsApp
E-mail
4 temas OPENEDG OPENEDG
Temario
4 sesiones Voucher
Curso
OPEN EDG
22 23-25 26 27 y 28 29
Febrero Febrero Febrero Febrero Febrero
THANK YOU!