Skip to content

Commit 37e2aac

Browse files
Add files via upload
1 parent d7534e9 commit 37e2aac

File tree

1 file changed

+268
-0
lines changed

1 file changed

+268
-0
lines changed

Assignment-19.ipynb

Lines changed: 268 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,268 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 15,
6+
"id": "3a18d2d1",
7+
"metadata": {},
8+
"outputs": [],
9+
"source": [
10+
"def double_char(s):\n",
11+
" dst=\"\"\n",
12+
" for i in s:\n",
13+
" m=i*2\n",
14+
" dst+=m\n",
15+
" return dst"
16+
]
17+
},
18+
{
19+
"cell_type": "code",
20+
"execution_count": 17,
21+
"id": "615e99b4",
22+
"metadata": {},
23+
"outputs": [
24+
{
25+
"name": "stdout",
26+
"output_type": "stream",
27+
"text": [
28+
"SSttrriinngg\n",
29+
"HHeelllloo WWoorrlldd!!\n",
30+
"11223344!!__ \n"
31+
]
32+
}
33+
],
34+
"source": [
35+
"print(double_char(\"String\"))\n",
36+
"print(double_char(\"Hello World!\"))\n",
37+
"print(double_char(\"1234!_ \"))"
38+
]
39+
},
40+
{
41+
"cell_type": "code",
42+
"execution_count": 20,
43+
"id": "115e8f20",
44+
"metadata": {},
45+
"outputs": [],
46+
"source": [
47+
"def reverse(b):\n",
48+
" if type(b) == bool:\n",
49+
" return not b\n",
50+
" elif b == 0:\n",
51+
" print(\"Boolean Expected\")\n",
52+
" else:\n",
53+
" print(\"Boolean Expected\")"
54+
]
55+
},
56+
{
57+
"cell_type": "code",
58+
"execution_count": 19,
59+
"id": "47995efb",
60+
"metadata": {},
61+
"outputs": [
62+
{
63+
"data": {
64+
"text/plain": [
65+
"False"
66+
]
67+
},
68+
"execution_count": 19,
69+
"metadata": {},
70+
"output_type": "execute_result"
71+
}
72+
],
73+
"source": [
74+
"reverse(True)"
75+
]
76+
},
77+
{
78+
"cell_type": "code",
79+
"execution_count": 21,
80+
"id": "da496622",
81+
"metadata": {},
82+
"outputs": [
83+
{
84+
"data": {
85+
"text/plain": [
86+
"True"
87+
]
88+
},
89+
"execution_count": 21,
90+
"metadata": {},
91+
"output_type": "execute_result"
92+
}
93+
],
94+
"source": [
95+
"reverse(False)"
96+
]
97+
},
98+
{
99+
"cell_type": "code",
100+
"execution_count": 22,
101+
"id": "a7f5f038",
102+
"metadata": {},
103+
"outputs": [
104+
{
105+
"name": "stdout",
106+
"output_type": "stream",
107+
"text": [
108+
"Boolean Expected\n"
109+
]
110+
}
111+
],
112+
"source": [
113+
"reverse(0)"
114+
]
115+
},
116+
{
117+
"cell_type": "code",
118+
"execution_count": 23,
119+
"id": "3d80c466",
120+
"metadata": {},
121+
"outputs": [
122+
{
123+
"name": "stdout",
124+
"output_type": "stream",
125+
"text": [
126+
"Boolean Expected\n"
127+
]
128+
}
129+
],
130+
"source": [
131+
"reverse(None)"
132+
]
133+
},
134+
{
135+
"cell_type": "code",
136+
"execution_count": 30,
137+
"id": "2ab410b3",
138+
"metadata": {},
139+
"outputs": [],
140+
"source": [
141+
"def num_layers(num):\n",
142+
" thickness = 0.5\n",
143+
" for i in range(num):\n",
144+
" thickness*=2\n",
145+
" return str(thickness/1000)+\"m\""
146+
]
147+
},
148+
{
149+
"cell_type": "code",
150+
"execution_count": 31,
151+
"id": "672311ff",
152+
"metadata": {},
153+
"outputs": [
154+
{
155+
"name": "stdout",
156+
"output_type": "stream",
157+
"text": [
158+
"0.001m\n",
159+
"0.008m\n",
160+
"1048.576m\n"
161+
]
162+
}
163+
],
164+
"source": [
165+
"print(num_layers(1))\n",
166+
"print(num_layers(4))\n",
167+
"print(num_layers(21))"
168+
]
169+
},
170+
{
171+
"cell_type": "code",
172+
"execution_count": 4,
173+
"id": "c7071e67",
174+
"metadata": {},
175+
"outputs": [],
176+
"source": [
177+
"def index_of_caps(s):\n",
178+
" lst=[]\n",
179+
" for i in s:\n",
180+
" if i.isupper() == True:\n",
181+
" lst.append(s.index(i))\n",
182+
" return lst\n",
183+
" "
184+
]
185+
},
186+
{
187+
"cell_type": "code",
188+
"execution_count": 6,
189+
"id": "f762db10",
190+
"metadata": {},
191+
"outputs": [
192+
{
193+
"name": "stdout",
194+
"output_type": "stream",
195+
"text": [
196+
"[1, 3, 5]\n",
197+
"[1, 3, 4, 6]\n",
198+
"[]\n",
199+
"[0, 1, 2, 3, 4, 5]\n",
200+
"[1]\n"
201+
]
202+
}
203+
],
204+
"source": [
205+
"print(index_of_caps(\"eDaBiT\"))\n",
206+
"print(index_of_caps(\"eQuINoX\") )\n",
207+
"print(index_of_caps(\"determine\") )\n",
208+
"print(index_of_caps(\"STRIKE\") )\n",
209+
"print(index_of_caps(\"sUn\") )"
210+
]
211+
},
212+
{
213+
"cell_type": "code",
214+
"execution_count": 36,
215+
"id": "2f4d0ee0",
216+
"metadata": {},
217+
"outputs": [],
218+
"source": [
219+
"def find_even_nums(n):\n",
220+
" a=1\n",
221+
" return [even for even in range(n+1) if even%2==0][1:]"
222+
]
223+
},
224+
{
225+
"cell_type": "code",
226+
"execution_count": 37,
227+
"id": "0328125b",
228+
"metadata": {},
229+
"outputs": [
230+
{
231+
"name": "stdout",
232+
"output_type": "stream",
233+
"text": [
234+
"[2, 4, 6, 8]\n",
235+
"[2, 4]\n",
236+
"[2]\n"
237+
]
238+
}
239+
],
240+
"source": [
241+
"print(find_even_nums(8))\n",
242+
"print(find_even_nums(4))\n",
243+
"print(find_even_nums(2))"
244+
]
245+
}
246+
],
247+
"metadata": {
248+
"kernelspec": {
249+
"display_name": "Python 3",
250+
"language": "python",
251+
"name": "python3"
252+
},
253+
"language_info": {
254+
"codemirror_mode": {
255+
"name": "ipython",
256+
"version": 3
257+
},
258+
"file_extension": ".py",
259+
"mimetype": "text/x-python",
260+
"name": "python",
261+
"nbconvert_exporter": "python",
262+
"pygments_lexer": "ipython3",
263+
"version": "3.6.9"
264+
}
265+
},
266+
"nbformat": 4,
267+
"nbformat_minor": 5
268+
}

0 commit comments

Comments
 (0)