Python Lessons - 5.3 Funtions on dictionaries m

Python Lesson – 5.3 Functions on dictionaries

Dictionaries already have a fairly complex structure and therefore various functions are needed to manage them. However, there are clauses in and not in that allow you to know whether a key is present in a dictionary, returning True in the first case, False in the second.

Python Lessons - 5.4 Tuples m

Python Lessons – 5.4 Tuples

After the lists and dictionaries, another type of structured data used is the tuple. The tuple is very similar to a list, except that once defined this is immutable (i.e. the values contained within cannot be modified). In Python, the tuple is recognizable as it is defined within parentheses ().

Python Lessons - 5.5 Slicing lists m

Python Lessons – 5.5 Slicing Lists

The slicing is a more advanced way of getting multiple items at the same time from a list. In fact if we want to get the elements between two indices of a list we can express the two extreme indexes separated by two points:

Python Lessons - 5.7 String formatting m

Python Lessons – 5.7 String formatting

You define a string in the classic method by inserting ascending integers enclosed in curly braces {}. Then the same string is referenced along with its format () method, where each argument will replace the numbers between the brackets {i} staples in the string.

Python Lesson - 6.1 Functional Programming m

Python Lessons – 6.1 Functional Programming

Functional programming is a programming style based solely on the use of functions. An important role of this type of programming plays it the higher-order functions. This kind of functions take other functions as arguments, or return functions.

Python Lesson - 6.2 Lambda functions m

Python Lesson – 6.2 Lambda functions

In Python, functions can also be used on the fly, using a particular syntax called Lambda. Functions that are created in this way are called Anonymous. This approach is often used when you want to pass a function as an argument to another function.

Python lessons - 6.3 Map and Filter m

Python Lessons – 6.3 Map and Filter

In Python, there is a built-in function called Map (), which can be very useful for high-order functions that operate on lists. In fact, this function takes a function and an Iterable object (such as a list) as arguments, and returns a new Iterable object (such as a new list) with the function applied for each argument

Python Lesson - 6.4 Generators m

Python Lessons – 6.4 Generators

Generators are a type of iterable, such as lists and tuples. But unlike lists, generators do not allow indexing with arbitrary indexes, but they can still be iterated through for loops. To define these generators you use the yield clause, replacing return within a function.