Skip to content

Commit 851673e

Browse files
committed
Add lambda.ipynb
1 parent 18db8e2 commit 851673e

File tree

1 file changed

+123
-0
lines changed

1 file changed

+123
-0
lines changed

function/lambda.ipynb

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 25,
6+
"metadata": {},
7+
"outputs": [
8+
{
9+
"name": "stdout",
10+
"output_type": "stream",
11+
"text": [
12+
"Hello Avik\n"
13+
]
14+
}
15+
],
16+
"source": [
17+
"# def greet(name):\n",
18+
"# print(\"Hello\", name)\n",
19+
"\n",
20+
"\n",
21+
"greet = lambda name : print(\"Hello\", name)\n",
22+
"\n",
23+
"# main\n",
24+
"greet(\"Avik\")"
25+
]
26+
},
27+
{
28+
"cell_type": "code",
29+
"execution_count": 26,
30+
"metadata": {},
31+
"outputs": [
32+
{
33+
"name": "stdout",
34+
"output_type": "stream",
35+
"text": [
36+
"Hello\n"
37+
]
38+
}
39+
],
40+
"source": [
41+
"# def greet():\n",
42+
"# print(\"Hello\")\n",
43+
"\n",
44+
"\n",
45+
"greet = lambda : print(\"Hello\") # lambda without argument(s)\n",
46+
"\n",
47+
"# main\n",
48+
"greet()"
49+
]
50+
},
51+
{
52+
"cell_type": "code",
53+
"execution_count": 27,
54+
"metadata": {},
55+
"outputs": [
56+
{
57+
"data": {
58+
"text/plain": [
59+
"11"
60+
]
61+
},
62+
"execution_count": 27,
63+
"metadata": {},
64+
"output_type": "execute_result"
65+
}
66+
],
67+
"source": [
68+
"sum = lambda a, b : a + b\n",
69+
"\n",
70+
"sum(5, 6)"
71+
]
72+
},
73+
{
74+
"cell_type": "code",
75+
"execution_count": 31,
76+
"metadata": {},
77+
"outputs": [
78+
{
79+
"data": {
80+
"text/plain": [
81+
"7"
82+
]
83+
},
84+
"execution_count": 31,
85+
"metadata": {},
86+
"output_type": "execute_result"
87+
}
88+
],
89+
"source": [
90+
"def func(x):\n",
91+
" return lambda y : y + x\n",
92+
"\n",
93+
"\n",
94+
"# main\n",
95+
"plus_two = func(2)\n",
96+
"\n",
97+
"plus_two(5)"
98+
]
99+
}
100+
],
101+
"metadata": {
102+
"kernelspec": {
103+
"display_name": "Python 3",
104+
"language": "python",
105+
"name": "python3"
106+
},
107+
"language_info": {
108+
"codemirror_mode": {
109+
"name": "ipython",
110+
"version": 3
111+
},
112+
"file_extension": ".py",
113+
"mimetype": "text/x-python",
114+
"name": "python",
115+
"nbconvert_exporter": "python",
116+
"pygments_lexer": "ipython3",
117+
"version": "3.11.4"
118+
},
119+
"orig_nbformat": 4
120+
},
121+
"nbformat": 4,
122+
"nbformat_minor": 2
123+
}

0 commit comments

Comments
 (0)