Skip to content

Commit 913f91d

Browse files
Add files via upload
1 parent f46b3c4 commit 913f91d

File tree

1 file changed

+226
-0
lines changed

1 file changed

+226
-0
lines changed

Assignment-15.ipynb

+226
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 2,
6+
"metadata": {},
7+
"outputs": [
8+
{
9+
"data": {
10+
"text/plain": [
11+
"3600"
12+
]
13+
},
14+
"execution_count": 2,
15+
"metadata": {},
16+
"output_type": "execute_result"
17+
}
18+
],
19+
"source": [
20+
"## In one hour there are 60 minutes in 60 minutes web have 60 seconds so multiplied by it\n",
21+
"onehour = 60 *60\n",
22+
"onehour"
23+
]
24+
},
25+
{
26+
"cell_type": "code",
27+
"execution_count": 3,
28+
"metadata": {},
29+
"outputs": [],
30+
"source": [
31+
"seconds_per_hour = onehour"
32+
]
33+
},
34+
{
35+
"cell_type": "code",
36+
"execution_count": 4,
37+
"metadata": {},
38+
"outputs": [
39+
{
40+
"data": {
41+
"text/plain": [
42+
"3600"
43+
]
44+
},
45+
"execution_count": 4,
46+
"metadata": {},
47+
"output_type": "execute_result"
48+
}
49+
],
50+
"source": [
51+
"seconds_per_hour"
52+
]
53+
},
54+
{
55+
"cell_type": "code",
56+
"execution_count": 5,
57+
"metadata": {},
58+
"outputs": [
59+
{
60+
"data": {
61+
"text/plain": [
62+
"86400"
63+
]
64+
},
65+
"execution_count": 5,
66+
"metadata": {},
67+
"output_type": "execute_result"
68+
}
69+
],
70+
"source": [
71+
"total_hours_in_day = 24\n",
72+
"day_in_seconds = seconds_per_hour * total_hours_in_day\n",
73+
"day_in_seconds"
74+
]
75+
},
76+
{
77+
"cell_type": "code",
78+
"execution_count": 7,
79+
"metadata": {},
80+
"outputs": [
81+
{
82+
"data": {
83+
"text/plain": [
84+
"86400"
85+
]
86+
},
87+
"execution_count": 7,
88+
"metadata": {},
89+
"output_type": "execute_result"
90+
}
91+
],
92+
"source": [
93+
"seconds_per_day = day_in_seconds\n",
94+
"seconds_per_day"
95+
]
96+
},
97+
{
98+
"cell_type": "code",
99+
"execution_count": 8,
100+
"metadata": {},
101+
"outputs": [
102+
{
103+
"data": {
104+
"text/plain": [
105+
"24.0"
106+
]
107+
},
108+
"execution_count": 8,
109+
"metadata": {},
110+
"output_type": "execute_result"
111+
}
112+
],
113+
"source": [
114+
"seconds_per_day/seconds_per_hour"
115+
]
116+
},
117+
{
118+
"cell_type": "code",
119+
"execution_count": 13,
120+
"metadata": {},
121+
"outputs": [
122+
{
123+
"data": {
124+
"text/plain": [
125+
"24"
126+
]
127+
},
128+
"execution_count": 13,
129+
"metadata": {},
130+
"output_type": "execute_result"
131+
}
132+
],
133+
"source": [
134+
"## According to question I Agree to floating-point value but converted to integer as we used floor division\n",
135+
"res = seconds_per_day//seconds_per_hour\n",
136+
"res"
137+
]
138+
},
139+
{
140+
"cell_type": "code",
141+
"execution_count": 12,
142+
"metadata": {},
143+
"outputs": [
144+
{
145+
"data": {
146+
"text/plain": [
147+
"int"
148+
]
149+
},
150+
"execution_count": 12,
151+
"metadata": {},
152+
"output_type": "execute_result"
153+
}
154+
],
155+
"source": [
156+
"type(res)"
157+
]
158+
},
159+
{
160+
"cell_type": "code",
161+
"execution_count": 7,
162+
"metadata": {},
163+
"outputs": [],
164+
"source": [
165+
"def genPrimes():\n",
166+
" lstprimenums = [] \n",
167+
" i = 1 \n",
168+
" while True:\n",
169+
" i = i + 1\n",
170+
" for p in lstprimenums:\n",
171+
" if i % p == 0:\n",
172+
" break\n",
173+
" else:\n",
174+
" lstprimenums.append(i)\n",
175+
" yield i"
176+
]
177+
},
178+
{
179+
"cell_type": "code",
180+
"execution_count": 9,
181+
"metadata": {},
182+
"outputs": [
183+
{
184+
"name": "stdout",
185+
"output_type": "stream",
186+
"text": [
187+
"2\n",
188+
"3\n",
189+
"5\n",
190+
"7\n",
191+
"11\n"
192+
]
193+
}
194+
],
195+
"source": [
196+
"output = genPrimes()\n",
197+
"print(next(output))\n",
198+
"print(next(output))\n",
199+
"print(next(output))\n",
200+
"print(next(output))\n",
201+
"print(next(output))"
202+
]
203+
}
204+
],
205+
"metadata": {
206+
"kernelspec": {
207+
"display_name": "Python 3",
208+
"language": "python",
209+
"name": "python3"
210+
},
211+
"language_info": {
212+
"codemirror_mode": {
213+
"name": "ipython",
214+
"version": 3
215+
},
216+
"file_extension": ".py",
217+
"mimetype": "text/x-python",
218+
"name": "python",
219+
"nbconvert_exporter": "python",
220+
"pygments_lexer": "ipython3",
221+
"version": "3.8.5"
222+
}
223+
},
224+
"nbformat": 4,
225+
"nbformat_minor": 4
226+
}

0 commit comments

Comments
 (0)