Slicing,non local,short circuiting

1-Work of slicing and indexing
2-use of non local.why it is used and different from using global x inside a function.
3-short circuiting in python

Slicing and indexing-
Using indexes you can extract a single character from a string.

what = ‘This parrot is dead’
what[3]
‘s’

what[0]
‘T’

Using slicing you can extract a contiguous piece of a string (known as a slice). x[start:end]

what[0:4]
‘This’

what[5:11]
‘parrot’

Global- Global variables are the one that are defined and declared outside a function and we need to use them inside a function. If a variable with same name is defined inside the scope of function as well then it will print the value given inside the function only and not the global value. To tell Python, that we want to use the global variable, we have to use the keyword “global”.

Non-local- This keyword works similar to the global, but rather than global, this keyword declares a variable to point to variable of outside enclosing function, in case of nested functions.But this keyword never checks for variable in global scope.

Short circuiting - It means stoppage of execution of boolean operation if the truth value of expression has been determined already.
or: When the Python interpreter scans or expression, it takes first statement and checks to see if it is true. If the first statement is true, then Python returns that object’s value without checking the second statement.
and: For an and expression, Python uses a short circuit technique to check if the first statement is false then the whole statement must be false, so it returns that value.