CSD203_-_FA_2024_-_PE_2872.webp
F

CSD203_-_FA_2024_-_PE_2872.webp

The class Product with 3 data members: Id, Name and Price is given and you do not need to edit it. The MyList class is a linked list of Product objects. The following methods should be completed:
def f1(self, id, name, price) - check if name end with "D" or id >100 or price >100 then do nothing,otherwise add new Product with Id = id, Name=name and Price=price to the last of the list. The id and price can get arbitrary value, even negative. Output in this case like that
OUTPUT
(-1, A, 5) (32, B, 23) (42, DE, 43) (45, E, 52) (26, F, 27) (18, H, 30) (36, XH, 51) (46, ZX, 5) (16, P, 20) (14, EC,10)
def f2(self, B) There is given object B (something like this Product (25,"BB", 10)) with id, name and price). You should write statements in method f2(self, B) to add the object B at before the second Product having Id is an odd number. Output in this case like that:
OUTPUT
(-1, Α, 5) (30, B, 23) (42, DE, 43) (45, E, 52) (26, F, 27) (11, Η, 30) (36, XH, 51) (46, ZX, 5) (16, P, 20) (14, EC,10)
(-1, A, 5) (30, B, 23) (42, DE, 43) (25, BB, 10) (45, E, 52) (26, F, 27) (11, H, 30) (36, XH, 51) (46, ZX, 5) (16, P,20) (14, EC, 10)
def f3(self, x) - Delete the first node having price is smaller than given x (x=20). Output in this case like that:
OUTPUT
Close
+ 100%
Zoom
Chưa có bình luận nào.

Thông tin

Category
CSD203
Thêm bởi
Fuery2002
Ngày thêm
Lượt xem
3,116
Lượt bình luận
0
Rating
0.00 star(s) 0 đánh giá

Image metadata

Filename
CSD203_-_FA_2024_-_PE_2872.webp
File size
233.8 KB
Dimensions
1920px x 813px

Share this media

Back
Bên trên Bottom