map and filter in Python
Example of the map function in Python. It takes a function and a list and apply that function to every item on the list… my_list = [2, 4, 3, 7, 8]map_object = map(lambda x: x*2,...
read moreTutorial Python Star Operator
Python’s star operator is used in many context. The simplest one is the multiplication operator … And the powers operator… It is used for extending lists… And similarly...
read moreTutorial on Python Dictionary
This is a tutorial on Python Dictionary. Here is an example dictionary… example = { "first_name": "Hello", "last_name": "World", "answer": 42} It consists of key value pairs. You can...
read moreUsing regular expressions in Python
To use regular expressions in Python, import the “re” module and use Python raw string for the regular expression pattern. For example, if you want to find all non-overlapping...
read moreJavascript Class Tutorial Example
In this tutorial, we will create a Shape class as an example which has a “sides” property that is initialized by the constructor… We create a new Shape instance and it prints out...
read morePython Class Tutorial Example
In this tutorial, we will create a Shape class as an example which has a “name” property that is initialized by the init() method… class Shape(): def __init__(self, name): ...
read morePython Decorators that can Take Parameters
What if you want the decorator to be able to take an parameter? Let’s create a “num_times” decorator that when applied will run the wrapped function “n” number of...
read morePython Tutorial Creating a custom decorator
In this Python tutorial, we will create a custom decorator named “print_start_time” which will wrap another function called “say_hello”. The say_hello function is simply...
read moreTutorial using namedtuples in Python
Instead of using a tuple, consider using a namedtuple instead, which is more self-documenting. Consider this function apply_color() which accepts a tuple of three values (which should be the red,...
read moreAll contents are opinions and are copyrighted and may contain display ads and ad links for which site may receive revenues from.
See Terms of Use and Privacy Policy.