Recent Changes - Search:

Oktatás

* Programozás 1
  + feladatsor
  + GitHub oldal

* Szkriptnyelvek
  + feladatsor
  + quick link

Teaching

* Programming 1 (BI)
  ◇ exercises
  ◇ quick link

teaching assets


Félévek

* 2025/26/2
* archívum


Linkek

* kalendárium
   - munkaszüneti napok '20
* tételsorok
* jegyzetek
* szakdolgozat / PhD
* ösztöndíjak
* certificates
* C lang.
* C++
* C#
* Clojure
* D lang.
* Java
* Nim
* Nim2
* Scala


[ edit | logout ]
[ sandbox | passwd ]

for loop

for i in 1..5:
  echo i

𝥶Closed interval. 5 is included. It prints the following values: 1, 2, 3, 4, 5

for i in 1 ..< 5:
  echo i

𝥶The interval is open on the right side. 5 is not included. Printed values: 1, 2, 3, 4

It's like Python's range(1, 5).

In Nim, 1..1_000_000 is a range expression that generates values lazily, one at a time. So it's similar to Python 3's range(). It doesn't build a sequence in the memory.

countup()

You need a step and you want values in increasing order.

The task is to print these values: 2, 4, 6, 8

countup()
for i in range(2, 10, 2):
    print(i)

In Python, the upper limit (here: 10) is not included.

for i in countup(2, 8, 2):
  echo i

Lower limit is 2, upper limit is 8 (included), and the step is 2.

countdown()

You need a step and you want values in decreasing order.

The task is to print these values: 10, 8, 6, 4, 2

countdown()
for i in range(10, 0, -2):
    print(i)
for i in countdown(10, 2, 2):
  echo i

Upper limit is 10, lower limit is 2 (included), and the step is 2.

Notice that the step is always positive! Even if you use countdown(), the step is still positive.

Cloud City

  

Blogjaim, hobbi projektjeim

* The Ubuntu Incident
* Python Adventures
* @GitHub
* heroku
* extra
* haladó Python
* YouTube listák


Debrecen | la France


[ edit ]

Edit - History - Print *** Report - Recent Changes - Search
Page last modified on 2026 April 05, 23:34