1/5
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Length check
len(itemoflength)
Range
Uses () not [], normal brackets are for functions like range and square brackets are for indexing
First argument is inclusive. Second argument is not. E.g. for i in range(0,7) will stop and not run if i is 7.
A third argument is the steps. This means you don’t have to increment i yourself. You can choose the direction and amount you want to increment, e.g. 3 or -1.
If you dont include a step, i will still increment by 1 always.
While loops don’t use in range
For loops automatically increment i because the range function has a step parameter even if you don’t sub it in.
No in range means you have to set i as 0 and increment it yourself
Select section of an array
arr[:3]
arr[2:]
First parameter inclusive, second is not
Making an empty 2D array
arr = [[0]*cols]*rows
where cols and rows are integers
Insertion sort
Cannot move all items along and then insert. Must shuffle it down one by one