Skip to content

Commit f0391de

Browse files
committed
updated
1 parent 503ea6b commit f0391de

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

004--basic-list-program.ipynb

+57
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,63 @@
203203
"pos1,pos2,pos3 =1,2,3\n",
204204
"print(swapposition(list,pos1-1,pos2-1,pos3-1))"
205205
]
206+
},
207+
{
208+
"cell_type": "markdown",
209+
"metadata": {},
210+
"source": [
211+
"- multiply all the numbers in the list"
212+
]
213+
},
214+
{
215+
"cell_type": "code",
216+
"execution_count": 2,
217+
"metadata": {},
218+
"outputs": [
219+
{
220+
"name": "stdout",
221+
"output_type": "stream",
222+
"text": [
223+
"1\n",
224+
"2\n"
225+
]
226+
}
227+
],
228+
"source": [
229+
"def multiplylist(mylist):\n",
230+
" result = 1\n",
231+
" for x in mylist :\n",
232+
" result =result * x\n",
233+
" return result\n",
234+
"l1 =[1,2,3]\n",
235+
"l2 =[2,4,6]\n",
236+
"print(multiplylist(l1))\n",
237+
"print(multiplylist(l2))\n"
238+
]
239+
},
240+
{
241+
"cell_type": "code",
242+
"execution_count": 3,
243+
"metadata": {},
244+
"outputs": [
245+
{
246+
"name": "stdout",
247+
"output_type": "stream",
248+
"text": [
249+
"6\n",
250+
"48\n"
251+
]
252+
}
253+
],
254+
"source": [
255+
"import numpy\n",
256+
"list1 = [1,2,3]\n",
257+
"list2 = [2,4,6]\n",
258+
"result1 =numpy.prod(list1)\n",
259+
"result2 =numpy.prod(list2)\n",
260+
"print(result1)\n",
261+
"print(result2)"
262+
]
206263
}
207264
],
208265
"metadata": {

0 commit comments

Comments
 (0)