Complete the class that outputs the median of the input values. If the input value is even, output the mean of the two median values. (However, the clear method deletes all input history)
This is the code I wrote by me I didn't know because I was learning the class this time. I received it as a for statement, appended it, sorted it, and made a median, but I don't know the link between the functions, so I'd appreciate it if you could let me know.python
First of all, I will tell you the biggest problem.
In get_item, create an empty list of items, and then self.Assign to the item. This way, whenever get_item is called, self.The item will be initialized. I can't collect more than two items.
I guess so
You can initialize the item list once in init and again when you empty it in clear.
© 2022 pinfo. All rights reserved.