Python Lessons – 2.8 Operations on lists
Now that we have seen how to create lists, we see in this section how to apply on them some operations that will prove very useful in programming in Python.
Never in the same shape
Now that we have seen how to create lists, we see in this section how to apply on them some operations that will prove very useful in programming in Python.
Python provides a good set of features that allow you to manipulate lists and their content efficiently.
Often in writing a program you have to use the same sequence of operations several times during the execution of a script or a program. It exists not only in Python, but in most programming languages to use both functions and modules just for that purpose.
It says call a function every time we used the following expression Nome_funzione ()
This is related to the concept of variable visibility. Variables defined outside the function also have value within the function, the variables used internally to the function do not have visibility outside (can not be used outside) and are destroyed as soon as Execution comes out of the operations inside the function.
The functions are able to return values at the end of their execution, and to do so you use the return clause.
In the Python language, comments are identified by inserting a # (sharp) sign at the beginning of the line. All text that will be written to this character later will be a comment and will not be considered at run time.
In Python Anything can be considered as a variable, even functions. In fact, although it may be very intuitive to start you can assign a function to a variable, in this way it is as if we had given a new name to the variable.
Modules are parts of code written by other programmers who perform functions that can be useful in many cases, so reusable in other codes. Each of these modules generally carries out a series of specialized operations in a given field that can be useful to reuse without having to rewrite the code from scratch.
All modules belonging to the last typology are part of a library called standard library. This library contains many modules, each specialized to fulfill certain operations.