Skip to content

0. Tutorial

Kamal Banga edited this page Oct 1, 2018 · 11 revisions

#ToDo Installation & Setup

Python repl

Print 0 to 9

>>> [i for i in range(10)])
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> list(range(10))
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> for i in range(10):
        print(i)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

range(n) object gives a list from 0 to n

Print even numbers in 0 to 9

[i for i in range(10) if i % 2 == 0]

Print squares of all numbers in 0 to 9

[i*i for i in range(10)]
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
  1. Dynamically-typed
  2. Arrays are lists.
  3. Has great data structures built-in: sets and dictionaries (key-value map, associative array)

This section is a stub, please move on to Reference

Test GIF

Direct links

Iterators

Bell Curve

Clone this wiki locally