Skip to content

Commit e1fe18a

Browse files
committed
After Course section6
1 parent 56bb5e1 commit e1fe18a

File tree

10 files changed

+30
-23
lines changed

10 files changed

+30
-23
lines changed

Section6/.idea/Section6.iml

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Section6/.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Section6/lecture61/Program1.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
class Person:
44

5-
country = "India" # class attributes
6-
75
def __init__(self,name, age):
86
self.name = name # instance attribute
97
self.age = age
@@ -15,4 +13,3 @@ def __init__(self,name, age):
1513
person2 = Person("Paul",32)
1614
print("person 2 name = ", person2.name)
1715
print("person 2 age = ", person2.age)
18-
print(" class attribute = ", Person.country)

Section6/lecture61/Program2.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Program to show classes and objects in Python
22

33
class Person:
4-
name = "" # class attribute
5-
age = 0
64

75
def run(self):
86
print("Person running")
@@ -12,13 +10,9 @@ def talk(self):
1210

1311

1412
person1 = Person()
15-
person1.name = "David"
16-
person1.age = 31
1713
person1.run()
1814
person1.talk()
1915
print("-------------------------------")
2016
person2 = Person()
21-
person2.name = "Paul"
22-
person2.age = 30
2317
person2.run()
2418
person2.talk()

Section6/lecture61/Program3.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Program to show class object attributes
2+
3+
4+
class Employee:
5+
company = "Udemy" # Class attribute
6+
7+
def __init__(self, name):
8+
self.name = name # instance attribute
9+
10+
11+
obj1 = Employee("David")
12+
print(obj1.name)
13+
print(obj1.company)
14+
print(Employee.company)
15+
16+

Section6/lecture63/Program2.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ def __init__(self, id, name):
88

99
def getid(self):
1010
return self.id
11+
1112
def setid(self, id):
1213
self.id = id
1314

Section6/lecture63/Program3.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,22 @@ def getbooks(self):
1010

1111
class Book:
1212

13-
def __init__(self ,name, isbn, author):
13+
def __init__(self, name, isbn, author):
1414
self.name = name
15-
self.isbn =isbn
15+
self.isbn = isbn
1616
self.author = author
1717

1818

1919
bookList = [Book("Book1", "122323-ww-ww", "David"),
2020
Book("Book2", "323332-rr-ee-ee32", "Ben"),
2121
Book("Book3", "223-ew-ee-e", "Paul"),
22-
Book("Book4", "yy-21-12y", "Adam")]
23-
bookstore = BookStore(bookList)
24-
for item in bookstore.books:
22+
Book("Book4", "yy-21-12y", "Adam")]
23+
bookstore = BookStore(bookList)
24+
for item in bookstore.getbooks():
2525
print("==========")
2626
print(item.name)
2727
print(item.isbn)
2828
print(item.author)
29-
30-
3129
print("==========")
3230

3331

Section6/lecture64/Program4.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ def fly(self):
99
class Eagle(Bird):
1010

1111
def fly(self):
12-
super(Eagle, self).fly()
13-
print("Eagle fly()")
12+
super().fly()
13+
print(" Eagle fly()")
1414

1515

1616
obj1 = Eagle()

Section6/lecture65/Program1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class Student:
44

55
def __init__(self, id, name):
6-
self.id =id
6+
self.id = id
77
self.name = name
88

99
def __str__(self):

Section6/lecture65/Program2.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ def __add__(self, other):
1616
return self.id + other.id
1717

1818

19-
2019
obj1 = Employee(12,"David")
2120
obj1 = Employee(12, "David")
2221

0 commit comments

Comments
 (0)