8000 added · imnaresh96/practice_python@afa068e · GitHub
[go: up one dir, main page]

Skip to content

Commit afa068e

Browse files
committed
added
1 parent bc5805b commit afa068e

File tree

2 files changed

+108
-13
lines changed

2 files changed

+108
-13
lines changed

Interview_Question.ipynb

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,109 @@
9898
"#### Usage: Lists are typically used to store collections of related data that can be changed, such as a list of names or a list of numbers. Tuples are often used to store related data that should not be changed, such as a pair of coordinates or a date and time."
9999
]
100100
},
101+
{
102+
"cell_type": "markdown",
103+
"id": "b79d3912",
104+
"metadata": {},
105+
"source": [
106+
"# Swap Number without Temp Variable"
107+
]
108+
},
109+
{
110+
"cell_type": "code",
111+
"execution_count": 1,
112+
"id": "c7dfe2d0",
113+
"metadata": {},
114+
"outputs": [
115+
{
116+
"name": "stdout",
117+
"output_type": "stream",
118+
"text": [
119+
"a=5 b=7\n",
120+
"a=7 b=5\n"
121+
]
122+
}
123+
],
124+
"source": [
125+
"a=5\n",
126+
"b=7\n",
127+
"print(f\"a={a} b={b}\")\n",
128+
"a,b=b,a\n",
129+
"print(f\"a={a} b={b}\")"
130+
]
131+
},
132+
{
133+
"cell_type": "code",
134+
"execution_count": 3,
135+
"id": "fb3be509",
136+
"metadata": {},
137+
"outputs": [],
138+
"source": [
139+
"def sum(*num):\n",
140+
" a=0\n",
141+
" for i in num:\n",
142+
" a+=i\n",
143+
" return(a)\n",
144+
" "
145+
]
146+
},
147+
{
148+
"cell_type": "code",
149+
"execution_count": 4,
150+
"id": "0ef6064b",
151+
"metadata": {},
152+
"outputs": [
153+
{
154+
"data": {
155+
"text/plain": [
156+
"34"
157+
]
158+
},
159+
"execution_count": 4,
160+
"metadata": {},
161+
"output_type": "execute_result"
162+
}
163+
],
164+
"source": [
165+
"sum(1,5,8,9,5,6)"
166+
]
167+
},
168+
{
169+
"cell_type": "code",
170+
"execution_count": 5,
171+
"id": "6f116cbd",
172+
"metadata": {},
173+
"outputs": [],
174+
"source": [
175+
"def detail(**name):\n",
176+
" return name"
177+
]
178+
},
179+
{
180+
"cell_type": "code",
181+
"execution_count": 7,
182+
"id": "54c50f4b",
183+
"metadata": {},
184+
"outputs": [
185+
{
186+
"data": {
187+
"text/plain": [
188+
"{'name': 'naresh', 'subject': 'Python'}"
189+
]
190+
},
191+
"execution_count": 7,
192+
"metadata": {},
193+
"output_type": "execute_result"
194+
}
195+
],
196+
"source": [
197+
"detail(name='naresh',subject='Python')"
198+
]
199+
},
101200
{
102201
"cell_type": "code",
103202
"execution_count": null,
104-
"id": "40b16cb1",
203+
"id": "f14b7229",
105204
"metadata": {},
106205
"outputs": [],
107206
"source": []

functions.ipynb

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@
793793
},
794794
{
795795
"cell_type": "code",
796-
"execution_count": 19,
796+
"execution_count": 1,
797797
"id": "ca269934",
798798
"metadata": {},
799799
"outputs": [],
@@ -805,7 +805,7 @@
805805
},
806806
{
807807
"cell_type": "code",
808-
"execution_count": 20,
808+
"execution_count": 2,
809809
"id": "aa7ffa76",
810810
"metadata": {},
811811
"outputs": [
@@ -816,7 +816,7 @@
816816
"traceback": [
817817
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
818818
"\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
819-
"\u001b[1;32mh:\\Python\\practice_python\\functions.ipynb Cell 46\u001b[0m in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> <a href='vscode-notebook-cell:/h%3A/Python/practice_python/functions.ipynb#X63sZmlsZQ%3D%3D?line=0'>1</a>\u001b[0m info(\u001b[39m'\u001b[39;49m\u001b[39mname\u001b[39;49m\u001b[39m'\u001b[39;49m)\n",
819+
"Input \u001b[1;32mIn [2]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43minfo\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mname\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m\n",
820820
"\u001b[1;31mTypeError\u001b[0m: info() takes 0 positional arguments but 1 was given"
821821
]
822822
}
@@ -827,19 +827,15 @@
827827
},
828828
{
829829
"cell_type": "code",
830-
"execution_count": 5,
830+
"execution_count": 3,
831831
"id": "85f3c75b",
832832
"metadata": {},
833833
"outputs": [
834834
{
835-
"ename": "NameError",
836-
"evalue": "name 'info' is not defined",
837-
"output_type": "error",
838-
"traceback": [
839-
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
840-
"\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)",
841-
"\u001b[1;32mh:\\Python\\practice_python\\functions.ipynb Cell 47\u001b[0m in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> <a href='vscode-notebook-cell:/h%3A/Python/practice_python/functions.ipynb#X64sZmlsZQ%3D%3D?line=0'>1</a>\u001b[0m info(name\u001b[39m=\u001b[39m\u001b[39m'\u001b[39m\u001b[39mnaresh\u001b[39m\u001b[39m'\u001b[39m,sub\u001b[39m=\u001b[39m\u001b[39m'\u001b[39m\u001b[39mpython\u001b[39m\u001b[39m'\u001b[39m)\n",
842-
"\u001b[1;31mNameError\u001b[0m: name 'info' is not defined"
835+
"name": "stdout",
836+
"output_type": "stream",
837+
"text": [
838+
"{'name': 'naresh', 'sub': 'python'}\n"
843839
]
844840
}
845841
],

0 commit comments

Comments
 (0)
0