Skip to content

Commit 96c41cc

Browse files
class assignment and datetime notebook
1 parent 89239f9 commit 96c41cc

File tree

4 files changed

+698
-46
lines changed

4 files changed

+698
-46
lines changed

Class/Assignment.txt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
1. Create an Employee Class with following attributes:
2+
a. employeeid - int
3+
b. name-string
4+
c. salary-int
5+
d. department-string
6+
e. email-string
7+
f. phone-int
8+
9+
10+
2. Write a Class Movie with following attributes:
11+
a. moviename - string
12+
b. imdbrating - float
13+
c. director - string
14+
d. actors - list
15+
e. genre - list
16+
17+
3. Write a Class Customer with following attributes:
18+
a. customerid - string
19+
b. customername - string
20+
c. email - string
21+
d. phone - int
22+
e. address - string
23+
24+
4. Write a Class Accounts with following attributes:
25+
a. accountid - int
26+
b. accountholdername - string
27+
c. ifsc code - string
28+
d. balance - float
29+
e. branch - string
30+
31+
5. Write a Class railwayticket with following attributes:
32+
a. ticketid - string
33+
b. passenger names - list ([{'name' : 'john','age':20},{'name' : 'jane','age':23}]
34+
c. fromstation - string
35+
d. tostation - string
36+
e. amount - float

Class/Classes.ipynb

Lines changed: 159 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
},
8686
{
8787
"cell_type": "code",
88-
"execution_count": 6,
88+
"execution_count": 4,
8989
"metadata": {},
9090
"outputs": [
9191
{
@@ -159,10 +159,154 @@
159159
"I will be explaining about the \"self\" in a while."
160160
]
161161
},
162+
{
163+
"cell_type": "code",
164+
"execution_count": 16,
165+
"metadata": {},
166+
"outputs": [
167+
{
168+
"name": "stdout",
169+
"output_type": "stream",
170+
"text": [
171+
"Movie Name- The Dark Knight\n",
172+
"Movie rating- 9.8\n",
173+
"Movie review- ['Must watch']\n"
174+
]
175+
}
176+
],
177+
"source": [
178+
"class movie:\n",
179+
" def __init__(self,name,rating,review):\n",
180+
" self.name=name\n",
181+
" self.rating=rating\n",
182+
" self.review=review\n",
183+
" def print_movie_details(self):\n",
184+
" print('Movie Name-',self.name)\n",
185+
" print('Movie rating-',self.rating)\n",
186+
" print('Movie review-',self.review)\n",
187+
"\n",
188+
"m1=movie('Batman',9.8,['Must watch'])\n",
189+
"# m1.print_movie_details()\n",
190+
"m2=movie('Breaking bad',9.9,['Must watch','outstanding'])\n",
191+
"# m2.print_movie_details()\n",
192+
"# print(m1.name,m2.name)\n",
193+
"m1.name='The Dark Knight'\n",
194+
"m1.print_movie_details()"
195+
]
196+
},
162197
{
163198
"cell_type": "code",
164199
"execution_count": 18,
165200
"metadata": {},
201+
"outputs": [
202+
{
203+
"data": {
204+
"text/plain": [
205+
"['__class__',\n",
206+
" '__delattr__',\n",
207+
" '__dict__',\n",
208+
" '__dir__',\n",
209+
" '__doc__',\n",
210+
" '__eq__',\n",
211+
" '__format__',\n",
212+
" '__ge__',\n",
213+
" '__getattribute__',\n",
214+
" '__gt__',\n",
215+
" '__hash__',\n",
216+
" '__init__',\n",
217+
" '__init_subclass__',\n",
218+
" '__le__',\n",
219+
" '__lt__',\n",
220+
" '__module__',\n",
221+
" '__ne__',\n",
222+
" '__new__',\n",
223+
" '__reduce__',\n",
224+
" '__reduce_ex__',\n",
225+
" '__repr__',\n",
226+
" '__setattr__',\n",
227+
" '__sizeof__',\n",
228+
" '__str__',\n",
229+
" '__subclasshook__',\n",
230+
" '__weakref__',\n",
231+
" 'print_movie_details']"
232+
]
233+
},
234+
"execution_count": 18,
235+
"metadata": {},
236+
"output_type": "execute_result"
237+
}
238+
],
239+
"source": [
240+
"dir(movie) # 1!=1"
241+
]
242+
},
243+
{
244+
"cell_type": "code",
245+
"execution_count": 19,
246+
"metadata": {},
247+
"outputs": [
248+
{
249+
"data": {
250+
"text/plain": [
251+
"True"
252+
]
253+
},
254+
"execution_count": 19,
255+
"metadata": {},
256+
"output_type": "execute_result"
257+
}
258+
],
259+
"source": [
260+
"int(1).__eq__(1) #1==1"
261+
]
262+
},
263+
{
264+
"cell_type": "code",
265+
"execution_count": 21,
266+
"metadata": {},
267+
"outputs": [
268+
{
269+
"data": {
270+
"text/plain": [
271+
"'100'"
272+
]
273+
},
274+
"execution_count": 21,
275+
"metadata": {},
276+
"output_type": "execute_result"
277+
}
278+
],
279+
"source": [
280+
"str=100\n",
281+
"int(str).__str__()"
282+
]
283+
},
284+
{
285+
"cell_type": "code",
286+
"execution_count": 26,
287+
"metadata": {},
288+
"outputs": [
289+
{
290+
"ename": "TypeError",
291+
"evalue": "'int' object is not callable",
292+
"output_type": "error",
293+
"traceback": [
294+
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
295+
"\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
296+
"\u001b[1;32m<ipython-input-26-d655c58c71c4>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[0mint\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'100'\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mstr\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'100'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
297+
"\u001b[1;31mTypeError\u001b[0m: 'int' object is not callable"
298+
]
299+
}
300+
],
301+
"source": [
302+
"int='100'\n",
303+
"str('100').int()"
304+
]
305+
},
306+
{
307+
"cell_type": "code",
308+
"execution_count": 10,
309+
"metadata": {},
166310
"outputs": [],
167311
"source": [
168312
"class FirstClass:\n",
@@ -185,21 +329,9 @@
185329
},
186330
{
187331
"cell_type": "code",
188-
"execution_count": 19,
332+
"execution_count": 11,
189333
"metadata": {},
190-
"outputs": [
191-
{
192-
"ename": "TypeError",
193-
"evalue": "__init__() takes 3 positional arguments but 4 were given",
194-
"output_type": "error",
195-
"traceback": [
196-
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
197-
"\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
198-
"\u001b[1;32m<ipython-input-19-00929d92741b>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0meg1\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mFirstClass\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'one'\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m3\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 2\u001b[0m \u001b[0meg2\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mFirstClass\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'two'\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
199-
"\u001b[1;31mTypeError\u001b[0m: __init__() takes 3 positional arguments but 4 were given"
200-
]
201-
}
202-
],
334+
"outputs": [],
203335
"source": [
204336
"eg1 = FirstClass('one',1)\n",
205337
"eg2 = FirstClass('two',2)"
@@ -326,7 +458,7 @@
326458
},
327459
{
328460
"cell_type": "code",
329-
"execution_count": 18,
461+
"execution_count": 17,
330462
"metadata": {},
331463
"outputs": [
332464
{
@@ -358,10 +490,11 @@
358490
" '__str__',\n",
359491
" '__subclasshook__',\n",
360492
" '__weakref__',\n",
361-
" 'test_demo']"
493+
" 'test_demo',\n",
494+
" 'test_demo1']"
362495
]
363496
},
364-
"execution_count": 18,
497+
"execution_count": 17,
365498
"metadata": {},
366499
"output_type": "execute_result"
367500
}
@@ -547,7 +680,7 @@
547680
},
548681
{
549682
"cell_type": "code",
550-
"execution_count": 20,
683+
"execution_count": 27,
551684
"metadata": {},
552685
"outputs": [],
553686
"source": [
@@ -559,7 +692,7 @@
559692
},
560693
{
561694
"cell_type": "code",
562-
"execution_count": 21,
695+
"execution_count": 28,
563696
"metadata": {},
564697
"outputs": [],
565698
"source": [
@@ -569,7 +702,7 @@
569702
},
570703
{
571704
"cell_type": "code",
572-
"execution_count": 22,
705+
"execution_count": 29,
573706
"metadata": {},
574707
"outputs": [
575708
{
@@ -588,15 +721,15 @@
588721
},
589722
{
590723
"cell_type": "code",
591-
"execution_count": 2,
724+
"execution_count": 30,
592725
"metadata": {},
593726
"outputs": [
594727
{
595728
"name": "stdout",
596729
"output_type": "stream",
597730
"text": [
598-
"10\n",
599-
"2\n",
731+
"10.34\n",
732+
"2.31\n",
600733
"33\n",
601734
"7\n",
602735
"260\n",
@@ -621,7 +754,7 @@
621754
" \n",
622755
" def division(self):\n",
623756
" print(self.number1/self.number2)\n",
624-
"eg1=calculator(10,2)\n",
757+
"eg1=calculator(10.34,2.31)\n",
625758
"print(eg1.number1)\n",
626759
"print(eg1.number2)\n",
627760
"eg1.number1=20\n",
@@ -1705,7 +1838,7 @@
17051838
"name": "python",
17061839
"nbconvert_exporter": "python",
17071840
"pygments_lexer": "ipython3",
1708-
"version": "3.8.5"
1841+
"version": "3.7.1"
17091842
}
17101843
},
17111844
"nbformat": 4,

0 commit comments

Comments
 (0)