Skip to content

Commit 5c0cc43

Browse files
Add files via upload
1 parent b3c4106 commit 5c0cc43

File tree

1 file changed

+205
-0
lines changed

1 file changed

+205
-0
lines changed

Assignment-15.ipynb

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 19,
6+
"id": "c185c20b",
7+
"metadata": {},
8+
"outputs": [],
9+
"source": [
10+
"def div(num):\n",
11+
" for i in range(num+1):\n",
12+
" if i%7==0 and i%5==0:\n",
13+
" yield i"
14+
]
15+
},
16+
{
17+
"cell_type": "code",
18+
"execution_count": 24,
19+
"id": "22c38c31",
20+
"metadata": {},
21+
"outputs": [
22+
{
23+
"name": "stdout",
24+
"output_type": "stream",
25+
"text": [
26+
"Enter number: 100\n",
27+
"0,35,70\n"
28+
]
29+
}
30+
],
31+
"source": [
32+
"num = int(input(\"Enter number: \"))\n",
33+
"lst=[]\n",
34+
"for i in div(num):\n",
35+
" lst.append(str(i))\n",
36+
"print(\",\".join(lst))"
37+
]
38+
},
39+
{
40+
"cell_type": "code",
41+
"execution_count": 25,
42+
"id": "05c99420",
43+
"metadata": {},
44+
"outputs": [],
45+
"source": [
46+
"def even(num):\n",
47+
" for i in range(num+1):\n",
48+
" if i%2==0:\n",
49+
" yield i"
50+
]
51+
},
52+
{
53+
"cell_type": "code",
54+
"execution_count": 27,
55+
"id": "1e41f637",
56+
"metadata": {},
57+
"outputs": [
58+
{
59+
"name": "stdout",
60+
"output_type": "stream",
61+
"text": [
62+
"Enter number: 20\n",
63+
"0,2,4,6,8,10,12,14,16,18,20\n"
64+
]
65+
}
66+
],
67+
"source": [
68+
"num = int(input(\"Enter number: \"))\n",
69+
"lst=[]\n",
70+
"for i in even(num):\n",
71+
" lst.append(str(i))\n",
72+
"print(\",\".join(lst))"
73+
]
74+
},
75+
{
76+
"cell_type": "code",
77+
"execution_count": 41,
78+
"id": "9f85052d",
79+
"metadata": {},
80+
"outputs": [
81+
{
82+
"name": "stdout",
83+
"output_type": "stream",
84+
"text": [
85+
"[0, 1, 1, 2, 3, 5, 8, 13, 21]\n"
86+
]
87+
}
88+
],
89+
"source": [
90+
"## fibonnaci series \n",
91+
"num=7\n",
92+
"lst=[0,1] \n",
93+
"[lst.append(lst[-2]+lst[-1]) for i in range(num)]\n",
94+
"print(lst) "
95+
]
96+
},
97+
{
98+
"cell_type": "code",
99+
"execution_count": 42,
100+
"id": "89ef7a94",
101+
"metadata": {},
102+
"outputs": [
103+
{
104+
"name": "stdout",
105+
"output_type": "stream",
106+
"text": [
107+
"1 2 3 5 8 13 21 "
108+
]
109+
}
110+
],
111+
"source": [
112+
"## Standard for loop of fibonnaci series\n",
113+
"a=0\n",
114+
"b=1\n",
115+
"for i in range(7):\n",
116+
" res=a+b\n",
117+
" print(res,end=\" \")\n",
118+
" a=b\n",
119+
" b=res\n"
120+
]
121+
},
122+
{
123+
"cell_type": "code",
124+
"execution_count": 44,
125+
"id": "0f49c476",
126+
"metadata": {},
127+
"outputs": [
128+
{
129+
"name": "stdout",
130+
"output_type": "stream",
131+
"text": [
132+
"john\n"
133+
]
134+
}
135+
],
136+
"source": [
137+
"email =\"john@google.com\".split(\"@\")\n",
138+
"print(email[0])"
139+
]
140+
},
141+
{
142+
"cell_type": "code",
143+
"execution_count": 58,
144+
"id": "dc9e82d0",
145+
"metadata": {},
146+
"outputs": [],
147+
"source": [
148+
"class Shape:\n",
149+
" def __init__(self):\n",
150+
" pass\n",
151+
" def area(self):\n",
152+
" return 0\n",
153+
"class Square(Shape):\n",
154+
" def __init__(self,length):\n",
155+
" Shape.__init__(self)\n",
156+
" self.length=length\n",
157+
" def area(self):\n",
158+
" return self.length **2"
159+
]
160+
},
161+
{
162+
"cell_type": "code",
163+
"execution_count": 60,
164+
"id": "fc127947",
165+
"metadata": {},
166+
"outputs": [
167+
{
168+
"name": "stdout",
169+
"output_type": "stream",
170+
"text": [
171+
"Area of Shape is 0\n",
172+
"Area of Square is 16\n"
173+
]
174+
}
175+
],
176+
"source": [
177+
"shapeobj = Shape()\n",
178+
"print(\"Area of Shape is \",shapeobj.area())\n",
179+
"squareobj = Square(4)\n",
180+
"print(\"Area of Square is \",squareobj.area())"
181+
]
182+
}
183+
],
184+
"metadata": {
185+
"kernelspec": {
186+
"display_name": "Python 3",
187+
"language": "python",
188+
"name": "python3"
189+
},
190+
"language_info": {
191+
"codemirror_mode": {
192+
"name": "ipython",
193+
"version": 3
194+
},
195+
"file_extension": ".py",
196+
"mimetype": "text/x-python",
197+
"name": "python",
198+
"nbconvert_exporter": "python",
199+
"pygments_lexer": "ipython3",
200+
"version": "3.6.9"
201+
}
202+
},
203+
"nbformat": 4,
204+
"nbformat_minor": 5
205+
}

0 commit comments

Comments
 (0)