Featured Post

14 Top Data Pipeline Key Terms Explained

Image
 Here are some key terms commonly used in data pipelines 1. Data Sources Definition: Points where data originates (e.g., databases, APIs, files, IoT devices). Examples: Relational databases (PostgreSQL, MySQL), APIs, cloud storage (S3), streaming data (Kafka), and on-premise systems. 2. Data Ingestion Definition: The process of importing or collecting raw data from various sources into a system for processing or storage. Methods: Batch ingestion, real-time/streaming ingestion. 3. Data Transformation Definition: Modifying, cleaning, or enriching data to make it usable for analysis or storage. Examples: Data cleaning (removing duplicates, fixing missing values). Data enrichment (joining with other data sources). ETL (Extract, Transform, Load). ELT (Extract, Load, Transform). 4. Data Storage Definition: Locations where data is stored after ingestion and transformation. Types: Data Lakes: Store raw, unstructured, or semi-structured data (e.g., S3, Azure Data Lake). Data Warehous...

Python Advanced For Loop With Example

Basically, For Loop reads input value and stores in a variable. So For Loop in Python needs two arguments. The two arguments are VARIABLE and IN. So far so good. The next part of the article and examples well explained how it works and how to get the index for each input supplied.

for loops in python

In Python, for loop list and count are related to the same logic. In the below example, I have taken one array and I counted using for loop, the number of elements in the input list.

For loop Syntax

for count in[1, 2, 3]: 
print(count)
print(’Yes’*count)

The first step, How the above syntax works are what I want to share with you. The 'in' represents input array for Python for loop. That means the for loop works 3 times in Python. It displays only 3 times. The third step is just to give 'yes', which will multiply with 'count' for 3 times.

This is the whole story of for loop in Python. In the second step, print just displays values of input that stored in the for loop variable of 'count'.

The 'count' gets values one by one from for loop input array. When you used the Shell to enter a loop, there was a reason that the interpreter waited to respond until after you entered an empty line: The interpreter did not know how long the loop block was going to be! The empty line is a signal to the interpreter that you are done with the loop block.

The index in For loop 

A small example is given to get index and value from for loop.
#Get index using for loop
#You will get index and value
mylist=[1, 2, 3]: 
for idx, val in enumerate(mylist):
    print(idx, val)

Video Tutorial

I have created a small video so that you can play quickly and check how for loop works in Python.
Also, read

Comments

Popular posts from this blog

How to Fix datetime Import Error in Python Quickly

SQL Query: 3 Methods for Calculating Cumulative SUM

Big Data: Top Cloud Computing Interview Questions (1 of 4)