Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5d73718

Browse files
Add files via upload
1 parent 37e2aac commit 5d73718

File tree

1 file changed

+204
-0
lines changed

1 file changed

+204
-0
lines changed

‎Assignment-20.ipynb

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"id": "651d3b59",
7+
"metadata": {},
8+
"outputs": [],
9+
"source": [
10+
"def filter_list(lst):\n",
11+
" nwlst = []\n",
12+
" for i in lst:\n",
13+
" if type(i) == int:\n",
14+
" nwlst.append(i)\n",
15+
" return nwlst"
16+
]
17+
},
18+
{
19+
"cell_type": "code",
20+
"execution_count": 2,
21+
"id": "d4892132",
22+
"metadata": {},
23+
"outputs": [
24+
{
25+
"name": "stdout",
26+
"output_type": "stream",
27+
"text": [
28+
"[1, 2, 3, 4]\n",
29+
"[0, 1729]\n",
30+
"[]\n"
31+
]
32+
}
33+
],
34+
"source": [
35+
"print(filter_list([1, 2, 3, \"a\", \"b\", 4]))\n",
36+
"print(filter_list([\"A\", 0, \"Edabit\", 1729, \"Python\", \"1729\"]))\n",
37+
"print(filter_list([\"Nothing\", \"here\"]))"
38+
]
39+
},
40+
{
41+
"cell_type": "code",
42+
"execution_count": 19,
43+
"id": "2dcc3299",
44+
"metadata": {},
45+
"outputs": [],
46+
"source": [
47+
"def add_indexes(lst):\n",
48+
" ilst = []\n",
49+
" for i in lst:\n",
50+
" m=lst.index(i)\n",
51+
" ilst.append(m+i)\n",
52+
" return ilst"
53+
]
54+
},
55+
{
56+
"cell_type": "code",
57+
"execution_count": 21,
58+
"id": "79a91cfc",
59+
"metadata": {},
60+
"outputs": [
61+
{
62+
"name": "stdout",
63+
"output_type": "stream",
64+
"text": [
65+
"[0, 0, 0, 0, 0]\n",
66+
"[1, 3, 5, 7, 9]\n",
67+
"[5, 5, 5, 5, 5]\n"
68+
]
69+
}
70+
],
71+
"source": [
72+
"print(add_indexes([0, 0, 0, 0, 0]) )\n",
73+
"print(add_indexes([1, 2, 3, 4, 5]) )\n",
74+
"print(add_indexes([5, 4, 3, 2, 1]))"
75+
]
76+
},
77+
{
78+
"cell_type": "code",
79+
"execution_count": 26,
80+
"id": "bcc272f2",
81+
"metadata": {},
82+
"outputs": [],
83+
"source": [
84+
"import math\n",
85+
"def cone_volume(r,h):\n",
86+
" return round(math.pi*(r**2)*h/3,2)"
87+
]
88+
},
89+
{
90+
"cell_type": "code",
91+
"execution_count": 29,
92+
"id": "6da516d0",
93+
"metadata": {},
94+
"outputs": [
95+
{
96+
"name": "stdout",
97+
"output_type": "stream",
98+
"text": [
99+
"12.57\n",
100+
"565.49\n",
101+
"0.0\n"
102+
]
103+
}
104+
],
105+
"source": [
106+
"print(cone_volume(2,3))\n",
107+
"print(cone_volume(6, 15))\n",
108+
"print(cone_volume(0, 18))"
109+
]
110+
},
111+
{
112+
"cell_type": "code",
113+
"execution_count": 54,
114+
"id": "ce736cdc",
115+
"metadata": {},
116+
"outputs": [],
117+
"source": [
118+
"def triangle(n):\n",
119+
" sum=0\n",
120+
" for i in range(1,n+1):\n",
121+
" sum = sum+i\n",
122+
" return sum "
123+
]
124+
},
125+
{
126+
"cell_type": "code",
127+
"execution_count": 62,
128+
"id": "98f0a21a",
129+
"metadata": {},
130+
"outputs": [
131+
{
132+
"name": "stdout",
133+
"output_type": "stream",
134+
"text": [
135+
"1\n",
136+
"21\n",
137+
"23220\n"
138+
]
139+
}
140+
],
141+
"source": [
142+
"print(triangle(1))\n",
143+
"print(triangle(6))\n",
144+
"print(triangle(215))"
145+
]
146+
},
147+
{
148+
"cell_type": "code",
149+
"execution_count": 44,
150+
"id": "8046502f",
151+
"metadata": {},
152+
"outputs": [],
153+
"source": [
154+
"def missing_num(lst):\n",
155+
" for i in range(1,10+1):\n",
156+
" if i not in lst:\n",
157+
" return i"
158+
]
159+
},
160+
{
161+
"cell_type": "code",
162+
"execution_count": 46,
163+
"id": "16bdeb4d",
164+
"metadata": {},
165+
"outputs": [
166+
{
167+
"name": "stdout",
168+
"output_type": "stream",
169+
"text": [
170+
"5\n",
171+
"10\n",
172+
"7\n"
173+
]
174+
}
175+
],
176+
"source": [
177+
"print(missing_num([1, 2, 3, 4, 6, 7, 8, 9, 10]))\n",
178+
"print(missing_num([7, 2, 3, 6, 5, 9, 1, 4, 8]))\n",
179+
"print(missing_num([10, 5, 1, 2, 4, 6, 8, 3, 9]))"
180+
]
181+
}
182+
],
183+
"metadata": {
184+
"kernelspec": {
185+
"display_name": "Python 3",
186+
"language": "python",
187+
"name": "python3"
188+
},
189+
"language_info": {
190+
"codemirror_mode": {
191+
"name": "ipython",
192+
"version": 3
193+
},
194+
"file_extension": ".py",
195+
"mimetype": "text/x-python",
196+
"name": "python",
197+
"nbconvert_exporter": "python",
198+
"pygments_lexer": "ipython3",
199+
"version": "3.6.9"
200+
}
201+
},
202+
"nbformat": 4,
203+
"nbformat_minor": 5
204+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /