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(lst) n The attribute roster cannot be defined, since it's not a parameter of the initializer. n The method enrol is correct. n The method enrol is incorrect because it doesn't properly add elements to the roster. n The method enrol is incorrect because it doesn't properly ignore duplicate string elements. n The method enrol is incorrect because it doesn't return anything. The initializer is incorrect as it creates more attributes than are passed. 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. --

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
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 = 0
def enrol(self, 1st: list[str]) -> None:
""" Add each element of <īst> to the roster once.
I" II II
for item in lst:
if item not in self.roster:
self.roster.append(lst)
n The attribute roster cannot be defined, since it's not a parameter of the initializer.
The method enrol is correct.
n The method enrol is incorrect because it doesn't properly add elements to the roster.
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.
n The command print(c.roster) prints the list roster, where c is an instance of myClass.
n The command print(c.roster) prints a memory address, as _repr__ or __str__ aren't defined.
---
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 = 0 def enrol(self, 1st: list[str]) -> None: """ Add each element of <īst> to the roster once. I" II II for item in lst: if item not in self.roster: self.roster.append(lst) n The attribute roster cannot be defined, since it's not a parameter of the initializer. The method enrol is correct. n The method enrol is incorrect because it doesn't properly add elements to the roster. 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. n The command print(c.roster) prints the list roster, where c is an instance of myClass. n The command print(c.roster) prints a memory address, as _repr__ or __str__ aren't defined. ---
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY