Kindly implement the PYTHON CODING given below and refer for the expected output of the program in the photo provided below! I will like your solution if you answered it correctly with complete solutions, thank you
Kindly implement the PYTHON CODING given below and refer for the expected output of the program in the photo provided below! I will like your solution if you answered it correctly with complete solutions, thank you
Kindly implement the PYTHON CODING given below and refer for the expected output of the program in the photo provided below! I will like your solution if you answered it correctly with complete solutions, thank you
Instructions: Kindly implement the PYTHON CODING given below and refer for the expected output of the program in the photo provided below! I will like your solution if you answered it correctly with complete solutions, thank you~
class Fish:
def __init__(self, size, name):
self.size = size
self.name = name
pass
def eat_fish(self, other_fish):
# TODO: Add method that simulates this fish
# trying to feed other_fish
if self.size > other_fish.size:
m = self.size + other_fish.size
return self.size
elif self.size < other_fish.size:
n = self.size + other_fish.size
return n
# This method returns the "winning" `Fish`
pass
def feed(self, pellet_size):
# TODO: Add method that simulates this fish
# feeding on a pellet of size pellet_size
#
# This method returns nothing (i.e. None)
pass
def main():
t = int(input())
for i in range(t):
n_fishes, n_evt = [int(x) for x in input().split()]
for _ in range(n_fishes):
name_f, size_f = input().split(maxsplit=1)
# TODO: process each fish with initial sizes
pass
for _ in range(n_evt):
evt, evt_args = input().split(maxsplit=1)
evt = evt.strip()
print(evt)
if evt == "eat":
evt_args = name_f, name_f
print(evt_args)
elif evt == "feed":
evt_args = name_f, size_f
print(evt_args)
# TODO: Process feeding events
# TODO: Print remaining fishes and fishes sorted in
# decreasing size
print(f"Case #{t}: Remaining fish(es):")
print(evt_args.eat_fish())
# HINT: Use `sorted()` with a `key` argument.
if __name__ == '__main__':
main()
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.