Python Programming
Lists in Python
 Python offers a range of compound datatypes
often referred to as sequences.
 Lists are a useful tool for preserving a sequence
of data and further iterating over it.
 Note:Like variables store 1 value, lists can be
used to store multiple values.
Lits has 4 atrributes
 Name of the list
 Values inside the list
 Length of list
 Calculated by len(list)
 Indexes of list
 Indexes of list start with 0 to (len(list) – 1)
Add elements to list
Strings are stored as lists in python
Functions in python
 In Python, function is a group of related
statements that perform a specific task.
 Functions help break our program into smaller
and modular chunks.
 As our program grows larger and larger,
functions make it more organized and
manageable.
Syntax of function
Return statement
Scope and Lifetime of variables
 Scope of a variable is the portion of a program
where the variable is recognized. Parameters
and variables defined inside a function is not
visible from outside. Hence, they have a local
scope.
 Lifetime of a variable is the period throughout
which the variable exits in the memory. The
lifetime of variables inside a function is as long
as the function executes.
 They are destroyed once we return from the
function. Hence, a function does not remember
This work is licensed under a Creative Commons
Attribution-ShareAlike 3.0 Unported License.
It makes use of the works of Mateus Machado Luna.

Python list functions

  • 1.
  • 2.
    Lists in Python Python offers a range of compound datatypes often referred to as sequences.  Lists are a useful tool for preserving a sequence of data and further iterating over it.  Note:Like variables store 1 value, lists can be used to store multiple values.
  • 4.
    Lits has 4atrributes  Name of the list  Values inside the list  Length of list  Calculated by len(list)  Indexes of list  Indexes of list start with 0 to (len(list) – 1)
  • 10.
  • 12.
    Strings are storedas lists in python
  • 15.
    Functions in python In Python, function is a group of related statements that perform a specific task.  Functions help break our program into smaller and modular chunks.  As our program grows larger and larger, functions make it more organized and manageable.
  • 16.
  • 18.
  • 19.
    Scope and Lifetimeof variables  Scope of a variable is the portion of a program where the variable is recognized. Parameters and variables defined inside a function is not visible from outside. Hence, they have a local scope.  Lifetime of a variable is the period throughout which the variable exits in the memory. The lifetime of variables inside a function is as long as the function executes.  They are destroyed once we return from the function. Hence, a function does not remember
  • 21.
    This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License. It makes use of the works of Mateus Machado Luna.