
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
![Given the following custom class myClass , which of the following statements are TRUE? Select all that apply.
class myClass:
def _init_(self, code, name):
self.code = code
self.name = name
self.roster = []
def enrol(self, 1st: list[str]) -> None:
" Add each element of <lst> to the roster once.
for item in 1st:
if item not in self.roster:
self.roster.append(1st)
The attribute roster cannot be defined, since it's not a parameter of the initializer.
O The method enrol is correct.
The method enrol is incorrect because it doesn't properly add elements to the roster.
O The method enrol is incorrect because it doesn't properly ignore duplicate string elements.
The method enrol is incorrect because it doesn't return anything.
The initializer is incorrect as it creates more attributes than are passed.
O The command print(c.roster) prints the list roster, where c is an instance of myClass.
The command print(c.roster) prints a memory address, as _repr_ or_str_ aren't defined.](https://content.bartleby.com/qna-images/question/84a55184-59cb-4c2c-8e9a-b4f3831e5579/965a071e-f27d-491f-9c2b-8ce680ac4af3/t9lghem_thumbnail.png)
Transcribed Image Text:Given the following custom class myClass , which of the following statements are TRUE? Select all that apply.
class myClass:
def _init_(self, code, name):
self.code = code
self.name = name
self.roster = []
def enrol(self, 1st: list[str]) -> None:
" Add each element of <lst> to the roster once.
for item in 1st:
if item not in self.roster:
self.roster.append(1st)
The attribute roster cannot be defined, since it's not a parameter of the initializer.
O The method enrol is correct.
The method enrol is incorrect because it doesn't properly add elements to the roster.
O The method enrol is incorrect because it doesn't properly ignore duplicate string elements.
The method enrol is incorrect because it doesn't return anything.
The initializer is incorrect as it creates more attributes than are passed.
O The command print(c.roster) prints the list roster, where c is an instance of myClass.
The command print(c.roster) prints a memory address, as _repr_ or_str_ aren't defined.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Write a class named Library. A library has the following attributes:• name: the name of this library.• employees: a list of LibraryEmployees that work at the library.• books: a dictionary that contains Books as keys. The value paired with each key is either anempty string, or a string representing the name of a person who has checked out the Book.The Library class should have an initializer that MAY accept employees and books as arguments,but doesn’t have to do so. If provided, these values should be assigned to the object’srespective attributes. If not provided, employees and books should begin as an empty list anddictionary, respectively. The value for the name attribute is always provided.The class should also have the following methods:• hire_employee(): takes in a new LibraryEmployee, and adds it to this library’s list ofemployees.• add_book(): takes in a new Book, and adds it to this library’s books (unless the libraryalready has this book). If the library already has the book,…arrow_forwardWrite a class named Library. A library has the following attributes:• name: the name of this library.• employees: a list of LibraryEmployees that work at the library.• books: a dictionary that contains Books as keys. The value paired with each key is either anempty string, or a string representing the name of a person who has checked out the Book.The Library class should have an initializer that MAY accept employees and books as arguments,but doesn’t have to do so. If provided, these values should be assigned to the object’srespective attributes. If not provided, employees and books should begin as an empty list anddictionary, respectively. The value for the name attribute is always provided.The class should also have the following methods:• hire_employee(): takes in a new LibraryEmployee, and adds it to this library’s list ofemployees.• add_book(): takes in a new Book, and adds it to this library’s books (unless the libraryalready has this book). If the library already has the book,…arrow_forwardWhich of the above choices (A, B, C or D) prints the name of each animal in the animalList object created from a previous question?// Assume that these accessor and mutator methods exist in the Animal class: // public void setAnimalName(String newName) { ... } // public String getAnimalName() { ... } // A for(int i = 0; i < animalList.length(); i++) { Animal tempAnimal = animalList[i]; System.out.println( tempAnimal.getAnimalName()); } // B for(int i = 0; i < animalList.length; i++) { Animal tempAnimal = animalList[i]; System.out.println( tempAnimal.getAnimalName()); } // C for(int i = 0; i < animalList.length; i++) { Animal tempAnimal = animalList[i]; System.out.println( tempAnimal.setAnimalName()); } // D for(int i = 0; i < animalList.length; i++) { Animal tempAnimal = animalList[i]; System.out.println(tempAnimal.animalName); }arrow_forward
- Given the following custom class myClass , which of the following statements are TRUE? Select all that apply. class myClass: def _init_(self, code, name): self.code = code self.name = name self.roster = [] def enrol(self, 1st: list[str]) -> None: """ Add each element of to the roster once. for item in 1st: if item not in self.roster: self.roster.append(1st) O The attribute roster cannot be defined, since it's not a parameter of the initializer. O The method enrol is correct. O The method enrol is incorrect because it doesn't properly add elements to the roster. O The method enrol is incorrect because it doesn't properly ignore duplicate string elements. O The method enrol is incorrect because it doesn't return anything. O The initializer is incorrect as it creates more attributes than are passed. O The command print(c.roster) prints the list roster, where cis an instance of myClass. O The command print(c.roster) prints a memory address, as _repr_ or_str_ aren't defined.arrow_forward• RectangleTest class: o Perform the following actions in the main method: • Create an object named r1 of the Rectangle class using the default constructor. • Using the set methods, initialize rl to have width 3.0 and length 5.2. • Use the printDimensions method to output all the data (width & length) related to r1. • Create another object named r2 of the Rectangle class with width 2.6 and length 5.4 using the overloaded constructor. • Print out r2 (width & length) using the get methods. • Print out the area and the perimeter of r1 using the calculateArea and calculatePerimeter methods. • Print out the area and the perimeter of r2 using the calculateArea and calculatePerimeter methods.arrow_forwardPlease create a driver class (java) that contains only a main method which should: Create a new CustomerList obiect Prompt the user to enter a file name Call the getCustomer List method with the file name that the user entered While (true) { Prompt user to enter command; if (command is "a") { Prompt user for customerNumber firstName lastName balance; Create a customerRecord and store it in the database; } else if (command is "f") { Prompt the user to enter a customer number and then displays the corresponding record on the screen; } else if (command is "g") { Prompt the user to enter a file name to save the latest update; Save the information in the database to the file specified by the user; Terminate program; } else { Display error message: } }arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education