CIC Hands On Python - s3
CIC Hands On Python - s3
Loops
An iterable is an object in Python that can return its members one at a time.
Why is this an infinite loop? Remember that while takes an expression and keeps repeating the code as long as that expression
evaluates to True. Since the very simple expression ‘True‘ is always True, this loop never stops.
Examples:
Functions
Parameters:
Functions accept a parameter, and you’ll see how this works in
a moment. The big advantage here, is that you can alter the
function’s behavior by changing the parameter.
Parameters
Return values:
A function can return a value. This value is often the result of
some calculation or operation. In fact, a Python function can
even return multiple values.
Return
Values
It’s just a few lines, but a lot is going on. Let’s dissect this:
Scope: The visibility of a variable is called scope. The scope defines which parts of your program can see and use a variable.