Loops are used for iterating over a sequence or block of code which you want to repeat a fixed number of times or until a certain condition is met.
Python supports various looping techniques by having some inbuilt functions. These methods are very useful in programming and also in maintaining the overall structure of code. They also help in saving a lot of time and memory as there is no need to declare the extra variables which we declare in the traditional approach of loops.
Let’s take a look at different looping techniques in Python:
enumerate() is used to loop…
In this tutorial we will learn how to use while loops in Python.
Loops are generally a block of code which you want to repeat a fixed number of times or until a certain condition is met. Python has two loop commands. They are :
Now let’s take a closer look at while loops and how they function.
While loops are used to execute a set of statements as long as the specific condition is true. The loop terminates immediately when the condition becomes false.
Syntax for a while loop:
In this tutorial we will cover the basic characteristics of Python dictionaries and learn how to access and manage dictionary data.
Dictionary is a collection of object that are unordered and changeable but works with keys and values instead of indexes. Dictionaries are similar to lists. The main difference between them is that the List elements are accessed by their position, via indexing whereas Dictionary elements are accessed via keys. In a dictionary, each key value pair maps the key to its associated value.
In Python, a dictionary is defined by enclosing a comma-separated list of key-value pairs in curly…
In this tutorial we will see how to write functions in python.
Functions are blocks (or lines) of code which allowing us to order our code, make it more readable, and reuse it. We can pass data, known as parameters, into a function. Also, a function can return data as a results.
Syntax of a function:
As discussed in the previous tutorial on Map functions, Filter, and Reduce are typical examples of functional programming. They allow us to write simpler, shorter code, without bothering about loops and branching.
Let us see how to use these functions in this tutorial.
Filter function returns boolean values (which is : true or false) and then passes each element in the iterable through the function, "filtering" away those that are false or we can say that it creates a list of elements for which a function returns true.
The filter() has the following syntax:
Only one iterable is…
Map, Filter, and Reduce are typical examples of functional programming. They allow us to write simpler, shorter code, without bothering about loops and branching.
In this tutorial we will see how to use the built-in map and filter functions in python.
Map comes built-in with Python (in the __builtins__ module) and need not be imported. Now let’s get a better understanding of how map works.
The map() function has the following syntax:
Where function is the function on which each element in iterables (as many as they are) would be applied on. The asterisk(*) means there can be…
In this Tutorial, we will learn invaluable skills that will form the foundation of our data processing work. Before we can apply machine learning algorithms or do different analyses on our data, we must clean and transform our data into suitable formats. Such initial data wrangling processes are often referred to as Extract Transform Load (ETL). Our primary tool of choice for performing ETL and basic analyses will be the Pandas package.
Pandas stands for “Python Data Analysis Library”. Pandas is extremely flexible when it comes to analyzing data with Python. …
What is an Index? Index is like an address, which lets us access data points across a dataframe or a series can be accessed. Both Rows and columns have indexes, rows indices are called as index and for columns its their general column names.
Thus, it is extremely important to understand Indexing rows and/or columns. In this tutorial, let’s look at some of the common ways of Indexing in Pandas.
Please install Pandas in case your system doesn’t have it installed.
! pip install pandas
Now let’s get started. …
Hand-driven and gravity fed water pumps are a key source of potable water throughout much of Africa and Asia, and the ongoing management and maintenance of such pumps is an ever-present challenge for many communities.Using data from Taarifa and the Tanzanian Ministry of Water, we want to predict which pumps are functional, which need some repairs, and which do not work at all.
We have several factors to go through to understand which of them help in the operations of the water pumps. …