DEV Community

SEAN
SEAN

Posted on

2 2

Day 5: Loops

Salutations!

Welcome to another day of exploration and my endeavours with the 30 days of code challenge, Day 5. Loops are the centre of todays attention.

Loops are a fundamental part of coding, which feature in almost all programming languages, so understanding them is paramount.

Python contains two different types of loops, the for loops and the while loop. For loops can iterate over a sequence of numbers using the range function. While loops repeat as long as a certain boolean condition is met.

Todays challenge involved using a loop to iterate over a variable 10 times and multiply it by the iteration number. i decided to do this in both styles of loop.

Here is my code for the for loop:
Alt Text
And here is the output:
Alt Text

Here is my code for the while loop:
Alt Text
and here is the output:
Alt Text

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

Introducing RTABench

To meet the need for real-time analytics workloads, we developed RTABench, a benchmark designed to test databases with these specific requirements. RTABench focuses on essential query patterns such as joins, filtering, and pre-aggregations.