-
Notifications
You must be signed in to change notification settings - Fork 0
0. Tutorial
#ToDo Installation & Setup
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]
- Dynamically-typed
- Arrays are lists.
- Has great data structures built-in: sets and dictionaries (key-value map, associative array)
From Introduction to Systems Notes
A coroutine is a routine which does not enforce a last-in first-out ordering on control transfers that we associate with procedures and functions. As a result, activation records for coroutines cannot usually be allocated on a stack, but must be allocated from a heap. Like a procedure, a coroutine is a body of code which must be associated with an activation record before it is run. Unlike procedures, however, the activation records for coroutines are not automatically allocated as a result of control transfers. Instead, the user must explicitly allocate coroutine activation records prior to a transfer of control, and the user may transfer control to a given coroutine, running in a given activation record, a number of times before that coroutine terminates.
The transfer of control to a coroutine is accomplished by a resume operation. This causes the computation which initiated the control transfer to be suspended, as a coroutine, and it causes the resumption of the computation to which control is transferred. As a result, two or more coroutine activations may easily transfer control back and forth, where each time a coroutine regains control, it picks up at the point it was most recently executing.
This section is a stub, please move on to Reference