Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement a class intlist which a list that stores only integers. You MUST subclass list. Please note the following: constructor can be passed a list

Implement a class intlist which a list that stores only integers. You MUST subclass list. Please note the following:

constructor –can be passed a list of ints, or, by default constructs an empty intlist.

append, insert,extend – can also be used to add ints to an intlist. If you don’t know how extend works for a list, look it up. All should raise errors if a non-int is added.

__setitem__- can be used for item assignment using an index. Raises error if non-int is used.

odds() – write a method odds() which returns an intlist consisting of the odd int’s. They should not be removed from the original.

evens() – same as odds(), but for even ints

NotIntError – also write an Exception class NotIntError that subclasses Exception.

NotIntError – a NonIntError should be raised when client code attempts to place something other than an int in an intlist. This can happen in three ways (all shown in code below):

append

insert

The constructor – when passed a list that contains something other an int

Step by Step Solution

3.45 Rating (158 Votes )

There are 3 Steps involved in it

Step: 1

class intlistlist l def initself li selfl li def setitemself key val ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Document Format ( 2 attachments)

PDF file Icon
609715b70d8ca_27478.pdf

180 KBs PDF File

Word file Icon
609715b70d8ca_27478.docx

120 KBs Word File

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Systems analysis and design

Authors: kenneth e. kendall, julie e. kendall

8th Edition

135094909, 013608916X, 9780135094907, 978-0136089162

More Books

Students also viewed these Programming questions

Question

How does the concept of hegemony relate to culture?

Answered: 1 week ago

Question

List the advantages of mounting applications on the Web.

Answered: 1 week ago