Skip to content

Commit

Permalink
new stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
mraza007 committed Jan 2, 2019
1 parent d65be7c commit a799526
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions markdown-version/lambdas.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,33 @@ for char in reversed("Hello"):
print(char)
# This will print out reversed hello
```


### Extras
- `abs()` this will return the absolute value.
- `sum()` this will sum a iterable like a list or tuple.
- `round()` This is going to round the number.

```python
x = -10
abs(x) # this is going to print 10
d = [1,2,3,4,5]
sum(d) # This will print the sum of the list.
f = 10.5
round(f) #This will print 11
```

### Zip()

- Make an iterator that aggregates elements from each of the iterables.
- Returns an iterator of tuples, where the i-th tuple contains the i-th elements from each of the arguement sequences or iterables.
- the iterator stops when the shortest input iterable is exhausted.

```python
x = [1,2,3]
y= [4,5,6]
zip(x,y)
# This will print(1,4),(2,5),(3,6)
# We can also convert it to a dictionary
dict(zip(x,y))
```

0 comments on commit a799526

Please sign in to comment.