Skip to content

Commit 17b13ff

Browse files
committed
update
1 parent 7585f64 commit 17b13ff

File tree

3 files changed

+388
-21
lines changed

3 files changed

+388
-21
lines changed

.ipynb_checkpoints/practice_for_solve_problem-checkpoint.ipynb

Lines changed: 243 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,18 @@
7777
},
7878
{
7979
"cell_type": "code",
80-
"execution_count": null,
80+
"execution_count": 11,
8181
"id": "fa569aab",
8282
"metadata": {},
83-
"outputs": [],
83+
"outputs": [
84+
{
85+
"name": "stdout",
86+
"output_type": "stream",
87+
"text": [
88+
"9\n"
89+
]
90+
}
91+
],
8492
"source": [
8593
"s=[4,5,6,9,8,5]\n",
8694
"n=0\n",
@@ -93,25 +101,252 @@
93101
},
94102
{
95103
"cell_type": "code",
96-
"execution_count": null,
104+
"execution_count": 13,
97105
"id": "b70a5307",
98106
"metadata": {},
99-
"outputs": [],
107+
"outputs": [
108+
{
109+
"name": "stdout",
110+
"output_type": "stream",
111+
"text": [
112+
"Enter something here: fdsss\n",
113+
"try again with other value\n"
114+
]
115+
}
116+
],
100117
"source": [
101118
"#reverses a string if its length is a multiple of 4.\n",
102119
"s=input('Enter something here: ')\n",
103120
"k=len(s)\n",
104-
"if k % 4==0:\n",
105-
" s[:-1]\n",
106-
" print(s)\n",
121+
"if k % 4 == 0:\n",
122+
" print(s[::-1])\n",
123+
" \n",
107124
"else:\n",
108125
" print('try again with other value')"
109126
]
110127
},
128+
{
129+
"cell_type": "code",
130+
"execution_count": 4,
131+
"id": "b761f2e3",
132+
"metadata": {},
133+
"outputs": [],
134+
"source": [
135+
"m='naresh'\n"
136+
]
137+
},
138+
{
139+
"cell_type": "code",
140+
"execution_count": 10,
141+
"id": "413ae1c2",
142+
"metadata": {},
143+
"outputs": [
144+
{
145+
"data": {
146+
"text/plain": [
147+
"'nares'"
148+
]
149+
},
150+
"execution_count": 10,
151+
"metadata": {},
152+
"output_type": "execute_result"
153+
}
154+
],
155+
"source": [
156+
"m[]"
157+
]
158+
},
159+
{
160+
"cell_type": "code",
161+
"execution_count": 19,
162+
"id": "24d3647a",
163+
"metadata": {},
164+
"outputs": [
165+
{
166+
"name": "stdout",
167+
"output_type": "stream",
168+
"text": [
169+
"nash\n"
170+
]
171+
}
172+
],
173+
"source": [
174+
"s='naresh'\n",
175+
"k=len(s)\n",
176+
"if k > 2:\n",
177+
" print(s[:2]+s[-2:])\n",
178+
"else:\n",
179+
" pass\n",
180+
" "
181+
]
182+
},
183+
{
184+
"cell_type": "code",
185+
"execution_count": 21,
186+
"id": "b2e56207",
187+
"metadata": {},
188+
"outputs": [
189+
{
190+
"name": "stdout",
191+
"output_type": "stream",
192+
"text": [
193+
"Enter Something here: naresh is not poor\n",
194+
"naresh is good\n"
195+
]
196+
}
197+
],
198+
"source": [
199+
"# replace 'not poor' to 'good'\n",
200+
"a=input('Enter Something here: ')\n",
201+
"k=a.replace('not poor','good')\n",
202+
"print(k)"
203+
]
204+
},
205+
{
206+
"cell_type": "code",
207+
"execution_count": 27,
208+
"id": "d33815a8",
209+
"metadata": {},
210+
"outputs": [
211+
{
212+
"name": "stdout",
213+
"output_type": "stream",
214+
"text": [
215+
"kuresh\n",
216+
"namar\n"
217+
]
218+
}
219+
],
220+
"source": [
221+
"k='naresh'\n",
222+
"m='kumar'\n",
223+
"print(m[:2]+k[2:])\n",
224+
"print(k[:2]+m[2:])"
225+
]
226+
},
227+
{
228+
"cell_type": "code",
229+
"execution_count": 32,
230+
"id": "ad7b32fa",
231+
"metadata": {},
232+
"outputs": [
233+
{
234+
"name": "stdout",
235+
"output_type": "stream",
236+
"text": [
237+
"naresh\n",
238+
"kumar\n",
239+
"ku resh\n",
240+
"na mar\n"
241+
]
242+
}
243+
],
244+
"source": [
245+
"k=input()\n",
246+
"m=input()\n",
247+
"l=' '\n",
248+
"print(m[:2]+ l +k[2:])\n",
249+
"print(k[:2]+ l +m[2:])"
250+
]
251+
},
252+
{
253+
"cell_type": "code",
254+
"execution_count": 39,
255+
"id": "8f814af2",
256+
"metadata": {},
257+
"outputs": [
258+
{
259+
"name": "stdout",
260+
"output_type": "stream",
261+
"text": [
262+
"1\n",
263+
"3\n",
264+
"6\n",
265+
"10\n",
266+
"15\n",
267+
"21\n",
268+
"28\n"
269+
]
270+
}
271+
],
272+
"source": [
273+
"s=7\n",
274+
"n=1\n",
275+
"sum=0\n",
276+
"while n<=s:\n",
277+
" sum=sum+n\n",
278+
" print(sum)\n",
279+
" n+=1"
280+
]
281+
},
282+
{
283+
"cell_type": "code",
284+
"execution_count": 51,
285+
"id": "46227e0b",
286+
"metadata": {},
287+
"outputs": [
288+
{
289+
"name": "stdout",
290+
"output_type": "stream",
291+
"text": [
292+
"1\n",
293+
"2\n",
294+
"3\n",
295+
"5\n",
296+
"8\n",
297+
"13\n",
298+
"21\n",
299+
"34\n"
300+
]
301+
}
302+
],
303+
"source": [
304+
"a=10\n",
305+
"b=0\n",
306+
"c=1\n",
307+
"for i in range(2, a):\n",
308+
" d=b+c\n",
309+
" b=c\n",
310+
" c=d\n",
311+
" print(d)"
312+
]
313+
},
314+
{
315+
"cell_type": "code",
316+
"execution_count": 52,
317+
"id": "16404fa7",
318+
"metadata": {},
319+
"outputs": [
320+
{
321+
"name": "stdout",
322+
"output_type": "stream",
323+
"text": [
324+
"8\n",
325+
"1\n",
326+
"2\n",
327+
"3\n",
328+
"5\n",
329+
"8\n",
330+
"13\n"
331+
]
332+
}
333+
],
334+
"source": [
335+
"\n",
336+
"a=int(input())\n",
337+
"b=0\n",
338+
"c=1\n",
339+
"for i in range(2, a):\n",
340+
" d=b+c\n",
341+
" b=c\n",
342+
" c=d\n",
343+
" print(d)"
344+
]
345+
},
111346
{
112347
"cell_type": "code",
113348
"execution_count": null,
114-
"id": "7f7ce970",
349+
"id": "9a52b5c8",
115350
"metadata": {},
116351
"outputs": [],
117352
"source": []

find_factorial.ipynb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,19 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": null,
5+
"execution_count": 1,
66
"id": "a6603976",
77
"metadata": {},
8-
"outputs": [],
8+
"outputs": [
9+
{
10+
"name": "stdout",
11+
"output_type": "stream",
12+
"text": [
13+
"Enter a number: 7\n",
14+
"the factorial of 7 is 5040\n"
15+
]
16+
}
17+
],
918
"source": [
1019
"num=int(input('Enter a number: '))\n",
1120
"factorial=1\n",

0 commit comments

Comments
 (0)