<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1:  Functions
Functions are blocks of code identified by a name, which can receive ""predetermined"" parameters or not ;).
In Python, functions
Step3:  In the above example, we have caps as function, which takes val as argument and returns val * 2.
Step4:  Functions can return any data type, next example returns a boolean value.
Step5:  Example (factorial without recursion)
Step7:  Example (factorial with recursion)
Step9:  Example (Fibonacci series with recursion)
Step10:  Example (Fibonacci series without recursion)
Step11:  NOTE
Step12:  Functions can also not return anything like in the below example
Step13:  Functions can also return multiple values, usually in form of tuple.
Step16:  Example (RGB conversion)
Step17:  Note
Step18:  Observations
Step19:  In the example, kargs will receive the named arguments and args will receive the others.
The interpreter has some builtin functions defined, including sorted(), which orders sequences, and cmp(), which makes comparisons between two arguments and returns -1 if the first element is greater, 0 (zero) if they are equal, or 1 if the latter is higher. This function is used by the routine of ordering, a behavior that can be modified.
Example
Step20:  Python also has a builtin function eval(), which evaluates code (source or object) and returns the value.
Example
<ASSISTANT_TASK:>
Python Code:
def caps(val):
    
    caps returns double the value of the provided value
    
    return val*2
a = caps("TEST ")
print(a)
print(caps.__doc__)
Explanation: Functions
Functions are blocks of code identified by a name, which can receive ""predetermined"" parameters or not ;).
In Python, functions:
return objects or not.
can provide documentation using Doc Strings.
Can have their properties changed (usually by decorators).
Have their own namespace (local scope), and therefore may obscure definitions of global scope.
Allows parameters to be passed by name. In this case, the parameters can be passed in any order.
Allows optional parameters (with pre-defined defaults ), thus if no parameter are provided then,  pre-defined default will be used.
Syntax:
python
def func(parameter1, parameter2=default_value):
    
    Doc String
    
    &lt;code block&gt;
    return value
NOTE: The parameters with default value must be declared after the ones without default value.
End of explanation
a = caps(1234)
print(a)
Explanation: In the above example, we have caps as function, which takes val as argument and returns val * 2.
End of explanation
def isValid(data):
    if 10 in data:
        return True
    return False
a = isValid([10, 200, 33, "asf"])
print(a)
a = isValid((10,))
print(a)
isValid((10,))
a = isValid((110,))
print(a)
def isValid_new(data):
    return 10 in data
print(isValid_new([10, 200, 33, "asf"]))
a = isValid_new((110,))
print(a)
Explanation: Functions can return any data type, next example returns a boolean value.
End of explanation
def fatorial(n):#{
    n = n if n > 1 else 1
    j = 1
    for i in range(1, n + 1):
        j = j * i
    return j
    #}
# Testing...
for i in range(1, 6):
    print (i, '->', fatorial(i))
Explanation: Example (factorial without recursion):
End of explanation
def factorial(num):
    Fatorial implemented with recursion.
    if num <= 1:
        return 1
    else:
        return(num * factorial(num - 1))
# Testing factorial()
print (factorial(5))
# 5 * (4 * (3 * (2) * (1))
Explanation: Example (factorial with recursion):
End of explanation
def fib(n):
    Fibonacci:
    fib(n) = fib(n - 1) + fib(n - 2) se n > 1
    fib(n) = 1 se n <= 1
    
    if n > 1:
        return fib(n - 1) + fib(n - 2)
    else:
        return 1
# Show Fibonacci from 1 to 5
for i in [1, 2, 3, 4, 5]:
    print (i, '=>', fib(i))
Explanation: Example (Fibonacci series with recursion):
End of explanation
def fib(n):    
    # the first two values
    l = [1, 1]
    
    # Calculating the others
    for i in range(2, n + 1):
        l.append(l[i -1] + l[i - 2])
        
    return l[n]
# Show Fibonacci from 1 to 5
for i in [1, 2, 3, 4, 5]:
    print (i, '=>', fib(i))
def test(a, b):
    print(a, b)
    return a + b
    
print(test(1, 2))
test(b=1, a=2)
def test_abc(a, b, c):
    print(a, b, c)
    return a + b + c
try:
    test_abc(b=1, a=2, 3)
except SyntaxError as e:
    print("error", e)
Explanation: Example (Fibonacci series without recursion):
End of explanation
test_abc(2, c=3, b=2)
test_abc(2, b=2, c=3)
Explanation: NOTE: We cannot have non-keyword arguments after keyword arguments
End of explanation
def test_new(a, b, c):
    pass
Explanation: Functions can also not return anything like in the below example
End of explanation
def test(a, b):
    print(a, b)
    return a*a, b*b
x, a = test(2, 5)
print(x)
print(type(x))
print(a)
print(type(a))
print(type(test(2, 5)))
def test(a, b):
    print(a, b)
    return a*a, b*b, a*b
x = test(2 , 5)
print(x)
print(type(x))
def test(a, b):
    print(a, b)
    return a*a, b*b, "asdf"
x = test(2 , 5)
print(x)
print(type(x))
def test(a=100, b=1000):
    print(a, b)
    return a, b
x = test(2, 5)
print(x)
print(test(10))
def test(a=100, b=1000):
    print(a, b)
    return a, b
print(test(b=10))
print(test(101))
def test(d, c, a=100, b=1000):
    print(d, c, a, b)
    return d, c, a, b
x = test(c=2, d=10, b=5)
print(x)
x = test(1, 2, 3, 4)
print(x)
print(test(10, 2))
Explanation: Functions can also return multiple values, usually in form of tuple.
End of explanation
def rgb_html(r=0, g=0, b=0):
    Converts R, G, B to #RRGGBB
    return '#%02x%02x%02x' % (r, g, b)
def html_rgb(color='#000000'):
    Converts #RRGGBB em R, G, B
    if color.startswith('#'): color = color[1:]
    r = int(color[:2], 16)
    g = int(color[2:4], 16)
    b = int(color[4:], 16)
    return r, g, b # a sequence
print (rgb_html(200, 200, 255))
print (rgb_html(b=200, g=200, r=255)) # what's happened? 
print (html_rgb('#c8c8ff'))
Explanation: Example (RGB conversion):
End of explanation
def test(d, a=100, c, b=1000):
    print(d, c, a, b)
    return d, c, a, b
x = test(c=2, d=10, b=5)
print(x)
x = test(1, 2, 3, 4)
print(x)
print(test(10, 2))
def test(c, d, a=100, b=1000):
    print(d, c, a, b)
    return d, c, a, b
x = test(c=2, d=10, b=5)
print(x)
x = test(1, 2, 3, 4)
print(x)
print(test(10, 2))
Explanation: Note: non-default argument's should always follow default argument
End of explanation
# *args - arguments without name (list)
# **kargs - arguments with name (ditcionary)
def func(*args, **kargs):
    print (args)
    print (kargs)
func('weigh', 10, unit='k')
Explanation: Observations:
The  arguments with default value must come last, after the non-default arguments.
The default value for a parameter is calculated when the function is defined.
The arguments passed without an identifier are received by the function in the form of a list.
The arguments passed to the function with an identifier are received in the form of a dictionary.
The parameters passed to the function with an identifier should come at the end of the parameter list.
Example of how to get all parameters:
End of explanation
def func(*args, **kargs):
    print (args)
    print (kargs)
a = {
    "name": "Mohan kumar Shah",
    "age": 24 + 1
}
func('weigh', 10, unit='k', val=a)
def func(*args):
    print(args)
func('weigh', 10, "test")
data = [(4, 3), (5, 1), (7, 2), (9, 0)]
# Comparing by the last element
def _cmp(x, y):
    return cmp(x[-1], y[-1])
print ('List:', data)
Explanation: In the example, kargs will receive the named arguments and args will receive the others.
The interpreter has some builtin functions defined, including sorted(), which orders sequences, and cmp(), which makes comparisons between two arguments and returns -1 if the first element is greater, 0 (zero) if they are equal, or 1 if the latter is higher. This function is used by the routine of ordering, a behavior that can be modified.
Example:
End of explanation
print (eval('12. / 2 + 3.3'))
def listing(lst):
    for l in lst:
        print(l)
       
d = {"Mayank Johri":40, "Janki Mohan Johri":68}
listing(d)
d = {
    "name": "Mohan",
    "age": 24
}
a = {
    "name": "Mohan kumar Shah",
    "age": 24 + 1
}
def process_dict(d=a):
    print(d)
process_dict(d)
process_dict()
Explanation: Python also has a builtin function eval(), which evaluates code (source or object) and returns the value.
Example:
End of explanation
<END_TASK>