|
| 1 | +#Multiple Inheritance |
| 2 | + |
| 3 | +class LetsUpgrade: |
| 4 | + lu_courses=[{'Subject': 'Maths', 'Trainer': 'Saikiran', 'Duration': 100}, |
| 5 | + {'Subject': 'Python', 'Trainer': 'Saikiran', 'Duration': 150}, |
| 6 | + {'Subject': 'Web design', 'Trainer': 'Prasad', 'Duration': 130}] |
| 7 | + |
| 8 | +class ITM: |
| 9 | + itm_courses=[{'Subject': 'Maths', 'Trainer': 'Sheetal', 'Duration': 90}, |
| 10 | + {'Subject': 'DSA', 'Trainer': 'Sumit', 'Duration': 200}, |
| 11 | + {'Subject': 'Computer Fundamentals', 'Trainer': 'Sumit', 'Duration': 150}] |
| 12 | + |
| 13 | +class CourseSelector(LetsUpgrade, ITM): |
| 14 | + def print_subjects(self, selected_class): |
| 15 | + if selected_class == 'LetsUpgrade': |
| 16 | + subjects = [course['Subject'] for course in self.lu_courses] |
| 17 | + elif selected_class == 'ITM': |
| 18 | + subjects = [course['Subject'] for course in self.itm_courses] |
| 19 | + else: |
| 20 | + subjects = [] |
| 21 | + |
| 22 | + if not subjects: |
| 23 | + print(f"No subjects available for {selected_class}") |
| 24 | + return |
| 25 | + |
| 26 | + print(f"Available subjects for {selected_class}: {subjects}") |
| 27 | + |
| 28 | + selected_subject = input("Enter the subject you want details for: ") |
| 29 | + |
| 30 | + if selected_subject in subjects: |
| 31 | + if selected_class == 'LetsUpgrade': |
| 32 | + selected_course = next(course for course in self.lu_courses if course['Subject'] == selected_subject) |
| 33 | + elif selected_class == 'ITM': |
| 34 | + selected_course = next(course for course in self.itm_courses if course['Subject'] == selected_subject) |
| 35 | + |
| 36 | + print(f"\nDetails of {selected_subject} in {selected_class}:") |
| 37 | + print(f"Trainer: {selected_course['Trainer']} sir") |
| 38 | + print(f"Duration: {selected_course['Duration']} hours") |
| 39 | + else: |
| 40 | + print(selected_subject, " is not available in ", selected_class) |
| 41 | + |
| 42 | + enroll_option = input("\nDo you wish to enroll? (yes/no): ").lower() |
| 43 | + |
| 44 | + if enroll_option == 'yes': |
| 45 | + name = input("Enter your Name: ") |
| 46 | + dob = input("Enter you DOB (DD/MM/YYYY): ") |
| 47 | + age = int(input("Enter your Age: ")) |
| 48 | + marks = int(input("Enter your 12th Marks: ")) |
| 49 | + location = input("Enter your Location: ") |
| 50 | + |
| 51 | + if marks >= 60: |
| 52 | + print("\nCongratulations! You are enrolled in ", selected_subject) |
| 53 | + print("\n----- Student Details -----") |
| 54 | + print("Name: ", name) |
| 55 | + print("Age: ", age) |
| 56 | + print("Date Of Birth: ", dob) |
| 57 | + print("12th Marks: ", marks, "%") |
| 58 | + print("Location: ", location) |
| 59 | + else: |
| 60 | + print("\nSorry! You are not eligible for this course.") |
| 61 | + |
| 62 | + else: |
| 63 | + print(selected_subject, " is not available in ", selected_class) |
| 64 | + |
| 65 | +course_selector = CourseSelector() |
| 66 | + |
| 67 | +selected_class = input("Enter the class (LetsUpgrade or ITM): ") |
| 68 | +course_selector.print_subjects(selected_class) |
| 69 | + |
| 70 | + |
0 commit comments