-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathonline_learn.py
More file actions
62 lines (47 loc) · 1.9 KB
/
Copy pathonline_learn.py
File metadata and controls
62 lines (47 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from abc import ABC, abstractmethod
# Abstract Base Class
class Course(ABC):
def __init__(self, course_name, duration):
self.course_name = course_name
self.duration = duration
@abstractmethod
def course_details(self):
pass
# Subclass - Programming Course
class ProgrammingCourse(Course):
def __init__(self, course_name, duration, language):
super().__init__(course_name, duration)
self.language = language
def course_details(self):
print("Course Name:", self.course_name)
print("Duration:", self.duration)
print("Programming Language:", self.language)
print("-----------------------------")
# Subclass - Design Course
class DesignCourse(Course):
def __init__(self, course_name, duration, software):
super().__init__(course_name, duration)
self.software = software
def course_details(self):
print("Course Name:", self.course_name)
print("Duration:", self.duration)
print("Design Software:", self.software)
print("-----------------------------")
# Subclass - Marketing Course
class MarketingCourse(Course):
def __init__(self, course_name, duration, specialization):
super().__init__(course_name, duration)
self.specialization = specialization
def course_details(self):
print("Course Name:", self.course_name)
print("Duration:", self.duration)
print("Marketing Specialization:", self.specialization)
print("-----------------------------")
# Creating Objects
prog = ProgrammingCourse("Python Development", "3 Months", "Python")
design = DesignCourse("Graphic Design", "2 Months", "Photoshop")
marketing = MarketingCourse("Digital Marketing", "4 Months", "SEO")
# Display Course Details
courses = [prog, design, marketing]
for course in courses:
course.course_details()