File tree 1 file changed +10
-0
lines changed
1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -105,17 +105,23 @@ Output
105
105
## max/min
106
106
* Returns the greatest/smallest item in an iterable or the smallest of two or more arguments.
107
107
* It can also be made to make use of key argument as used in sort function
108
+
108
109
### implementation
110
+
109
111
``` python
112
+
110
113
list = [1 , 4 , 3 , 5 ,9 ,2 ]
111
114
print (max (list )) # returns maximum value of list
112
115
print (min (list )) # returns minimum value in the list
113
116
print (max (list[2 :- 2 ])) # returns max value combined with slicing
114
117
print (min (list[4 :])
115
118
print (max (4 ,2 ,3 ,5 ))
116
119
print (min (7 ,2 ,1 ,8 ,4 ))
120
+
117
121
```
122
+
118
123
Output
124
+
119
125
```
120
126
9
121
127
1
@@ -126,13 +132,17 @@ Output
126
132
127
133
```
128
134
135
+
136
+
137
+
129
138
# # Reduce
130
139
* Reduce is a really useful function for performing some computation on a list and returning the result.
131
140
* It applies a rolling computation to sequential pairs of values in a list
132
141
> note this not an inbuilt function as such because it needs to be imported from func tools but is pretty useful.
133
142
134
143
# ## implementation
135
144
```python
145
+
136
146
# Normal way to find product of elements in a list
137
147
product = 1
138
148
list = [1 , 2 , 3 , 4 ]
You can’t perform that action at this time.
0 commit comments