Answered step by step
Verified Expert Solution
Question
1 Approved Answer
5. Write a Python function named pattern that accepts two arguments (an integer and a string) and prints the character to form a triangular shape,
5. Write a Python function named "pattern" that accepts two arguments (an integer and a string) and prints the character to form a triangular shape, as shown below: For example, pattern (8,"ABC ") produces: BCABCABCBABCABABCCABABCBCABCABC 6. Define a class named Book that keeps track of book objects such that the instance data contains the book's title, author (protected member), year (private mamber) and a unique identification number, say id that starts form 1 for the first book object and is incremented by 1 each time a new book with at least the title specified is created. The required methods in the Book class are as follows: (i) At least the title should be defined for each object. The properties author and year may be initialized as "Unknown" and 0 respectively. (ii) there are setter (set_year) and getter (get_year) methods for the year property. (ii) a setter (set_author) method for the author property. 7. Use the class defined in question 6 for the followings: (i) Create a list of 8 objects by using the class defined in question 6 . Design your code to use all methods explained. (ii) Write a code to display the list of books. Each book should be on a new line with the following order: id, author, title,year (iii) Create a list of author names (at least 5 names) and write a loop to display the book names of each author if that author has any book 8. Define an abstract class named animal that has properties of name, brand and num_of_legs. This class has an abstract class named motion. Then define the following child classes: (i) A bird class where the motion method displays " "name" can fly"; (ii) A dog class where the motion method displays " "name" can run"; (iii) define a fish class where the motion method displays " "name" can swim
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started