Connect 4 Techs
  • Home
  • Excel
  • Data Analysis
  • Finance
  • MBA
    • Marketing
  • Kotlin
  • Gadgets
    • Apple
    • Samsung
    • Canon
    • Tech News
  • About
  • Contact
No Result
View All Result
Connect 4 Techs
  • Home
  • Excel
  • Data Analysis
  • Finance
  • MBA
    • Marketing
  • Kotlin
  • Gadgets
    • Apple
    • Samsung
    • Canon
    • Tech News
  • About
  • Contact
No Result
View All Result
Connect 4 Techs
No Result
View All Result
Home Kotlin

Kotlin For Loop & Kotlin Ranges (Lesson 10 PDF)

Ahmed Elhozayen by Ahmed Elhozayen
October 11, 2026
in Kotlin
0
Kotlin For Loop & Kotlin Ranges (Lesson 10 PDF)

Kotlin is a statically typed programming language that runs on the Java Virtual Machine (JVM). It was developed by JetBrains and is now an official language for Android development. Kotlin is designed to be concise, expressive, and safe.

It is also interoperable with Java, which means that you can use Kotlin and Java code together in the same project.

You might also like

Kotlin Class Functions & Inheritance (Lesson 13 PDF)

Kotlin Classes and Objects & Constructors (Lesson 12 PDF)

Kotlin Functions & Classes (Lesson 11 PDF)

Kotlin

Kotlin For Loop & Kotlin Ranges (Lesson 10 PDF)

Overview about the Lesson

In this lesson, we’ll cover the basics of Kotlin For Loop & Kotlin Ranges, including how to create and initialize ranges, how to access and modify range elements, and how to traverse ranges.

Kotlin For Loop & Kotlin Ranges (Lesson 10 PDF) – page 2
Kotlin For Loop & Kotlin Ranges (Lesson 10 PDF) – page 3
Kotlin For Loop & Kotlin Ranges (Lesson 10 PDF) – page 4

The Content Of The Lesson

The lesson is divided into the following sections:

  • Creating and initializing ranges
  • Accessing and modifying range elements
  • Traversing ranges
  • Using for loop with ranges
  • Using while loop with ranges
  • Using do-while loop with ranges

Why This Lesson

For Loop & Ranges are fundamental concepts in programming, and Kotlin provides excellent support for working with them. By the end of this lesson, you’ll have a solid understanding of Kotlin For Loop & Kotlin Ranges and how to use them in your programs.

Kotlin for Loops and Ranges: Examples

The PDF covers for loops and ranges. These examples show every common form, with the output you should see.

Ranges

ExpressionValuesNote
1..51, 2, 3, 4, 5Inclusive at both ends
1 until 51, 2, 3, 4Excludes the end (also written 1..<5)
5 downTo 15, 4, 3, 2, 1Counts down
1..10 step 31, 4, 7, 10Custom step
‘a’..’e’a, b, c, d, eCharacter ranges work too

Check membership with in: if (age in 13..19) println("Teenager").

for loop forms

fun main() {
    for (i in 1..3) print("$i ")          // 1 2 3
    println()
    for (i in 10 downTo 0 step 5) print("$i ")  // 10 5 0
    println()

    val colors = listOf("red", "green", "blue")
    for (c in colors) println(c)

    for ((index, c) in colors.withIndex()) {
        println("$index -> $c")           // 0 -> red, 1 -> green, 2 -> blue
    }

    val prices = mapOf("tea" to 2.5, "coffee" to 3.0)
    for ((item, price) in prices) println("$item costs $price")
}

Kotlin has no C-style for (int i = 0; i < n; i++). Ranges replace it: for (i in 0 until n).

repeat and forEach

fun main() {
    repeat(3) { println("Hello #$it") }   // it = 0, 1, 2
    (1..3).forEach { print(it * it) }      // 149
}

repeat(n) is the simplest way to run something n times. Inside forEach, use return@forEach to skip to the next item.

Nested loops and labels

fun main() {
    outer@ for (row in 1..3) {
        for (col in 1..3) {
            if (row * col == 4) break@outer   // leaves both loops
            print("${row * col} ")
        }
    }
}
// Output: 1 2 3 2

A label (outer@) lets break or continue act on the outer loop instead of the inner one.

Practice exercise

Print the multiplication table of 7 from 7 × 1 to 7 × 10.

fun main() {
    for (i in 1..10) {
        println("7 x $i = ${7 * i}")
    }
}

Frequently Asked Questions

What is the difference between .. and until?

1..5 includes 5; 1 until 5 stops at 4. Use until (or ..<) when looping over indexes, e.g. for (i in 0 until list.size), or simply list.indices.

Can I loop backwards over a list?

Yes: for (i in list.indices.reversed()) or for (item in list.asReversed()).

Continue the course

← Previous: Lesson 9: Arrays  |  Next: Lesson 11: Functions & Classes →

  1. Lesson 1: Getting Started
  2. Lesson 2: Syntax & Output
  3. Lesson 3: Comments & Variables
  4. Lesson 4: Data Types
  5. Lesson 5: Operators
  6. Lesson 6: Set Operations & Grouping
  7. Lesson 7: Booleans & If…Else
  8. Lesson 8: When, While, Break & Continue
  9. Lesson 9: Arrays
  10. Lesson 10: For Loops & Ranges (you are here)
  11. Lesson 11: Functions & Classes
  12. Lesson 12: Classes, Objects & Constructors
  13. Lesson 13: Class Functions & Inheritance

Conclusion

In this blog post, we’ve covered the basics of Kotlin For Loop & Kotlin Ranges, including how to create and initialize ranges, how to access and modify range elements, and how to traverse ranges.

We’ve also explored some advanced topics, such as using for loop, while loop, and do-while loop with ranges. With this knowledge, you’ll be well-equipped to work with For Loop & Ranges in your Kotlin programs.

Download From Link

You can download the lesson from the following link:

From Here

Tags: AndroidJavaJVMKotlinProgrammingtechnology
Previous Post

 Kotlin Arrays (Lesson 9 PDF)

Next Post

Kotlin Functions & Classes (Lesson 11 PDF)

Ahmed Elhozayen

Ahmed Elhozayen

Ahmed Elhozayen writes and curates the guides on Connect4Techs Tech. He works in the IT field and focuses on practical, step-by-step resources for Excel, data analysis, finance, MBA studies and Kotlin programming, so readers can apply what they learn the same day.

Related Posts

Kotlin Class Functions & Inheritance (Lesson 13 PDF)
Kotlin

Kotlin Class Functions & Inheritance (Lesson 13 PDF)

by Ahmed Elhozayen
October 11, 2026
Kotlin Classes and Objects & Constructors (Lesson 12 PDF)
Kotlin

Kotlin Classes and Objects & Constructors (Lesson 12 PDF)

by Ahmed Elhozayen
October 11, 2026
Kotlin Functions & Classes (Lesson 11 PDF)
Kotlin

Kotlin Functions & Classes (Lesson 11 PDF)

by Ahmed Elhozayen
October 11, 2026
 Kotlin Arrays (Lesson 9 PDF)
Kotlin

 Kotlin Arrays (Lesson 9 PDF)

by Ahmed Elhozayen
October 11, 2026
Kotlin When & While Loop, Break & Continue (Lesson 8 PDF)
Kotlin

Kotlin When & While Loop, Break & Continue (Lesson 8 PDF)

by Ahmed Elhozayen
October 11, 2026
Next Post
Kotlin Functions & Classes (Lesson 11 PDF)

Kotlin Functions & Classes (Lesson 11 PDF)

Recommended

Career Development in an MBA Program PDF Guide

Career Development in an MBA Program PDF Guide

June 26, 2024
Data Analysis by MS Excel PDF

Excel Formulas Bible PDF

March 21, 2025

Categories

  • apple
  • Canon
  • Data Analysis
  • Excel
  • Finance
  • ios
  • Kotlin
  • Marketing
  • MBA
  • Samsung
  • Software Tutorials
  • Technology

Don't miss it

20 Essential Excel Formulas Every Data Analyst Must Know in 2026
Data Analysis

20 Essential Excel Formulas Every Data Analyst Must Know in 2026

May 18, 2026
Excel guide for data analytics learners
Excel

Excel for Data Analysis PDF

October 11, 2026
The Ultimate Guide to Financial Modeling PDF
Excel

The Ultimate Guide to Financial Modeling PDF

October 11, 2026
The Ultimate Excel Handbook PDF
Excel

The Ultimate Excel Handbook PDF

October 11, 2026
𝟓𝟎 𝐄𝐱𝐜𝐞𝐥 𝐒𝐡𝐨𝐫𝐭𝐜𝐮𝐭 𝐊𝐞𝐲
Excel

50 Excel Shortcut Key PDF: Streamline Your Workflow

March 21, 2025
Most Useful Excel Keyboard Shortcuts For Windows and Mac OS
Excel

Most Useful Excel Keyboard Shortcuts for Windows and Mac OS PDF

March 21, 2025
Connect4Techs Tech

Practical, free guides on Excel, data analysis, finance, business and programming — written to help you learn faster and work smarter.

Follow on Facebook

Topics

  • Excel
  • Kotlin
  • MBA
  • Finance
  • Data Analysis
  • Apple
  • Technology
  • Software Tutorials

Latest articles

  • 20 Essential Excel Formulas Every Data Analyst Must Know in 2026May 18, 2026
  • Excel for Data Analysis PDFAug 31, 2025
  • The Ultimate Guide to Financial Modeling PDFApr 19, 2025

Company

  • About us
  • Contact
  • Privacy Policy
  • Terms of Use
  • IT Certification PDFs
  • AI Tools & News (Connect4AI)
© 2026 Connect4Techs. All rights reserved. Privacy · Terms · Contact
No Result
View All Result
  • Home
  • Excel
  • Data Analysis
  • Finance
  • MBA
    • Marketing
  • Kotlin
  • Gadgets
    • Apple
    • Samsung
    • Canon
    • Tech News
  • About
  • Contact