Penghargaan Menkominfo

Опубликовано: 12 Май 2026
на канале: ZEN
28
2

coba jelaskan kode ini jika kalian adalah frogramer : class Character:
def __init__(self, name, species, role):
self.name = name
self.species = species
self.role = role

class Location:
def __init__(self, name, description):
self.name = name
self.description = description

class Show:
def __init__(self, title, characters, locations, plot):
self.title = title
self.characters = characters
self.locations = locations
self.plot = plot

Characters
hero = Character(name="Hero", species="Sea Sponge", role="Cook")
friend = Character(name="Friend", species="Starfish", role="Sidekick")
neighbor = Character(name="Neighbor", species="Squid", role="Grump")
villain = Character(name="Villain", species="Plankton", role="Thief")

Locations
restaurant = Location(name="Krusty Krab", description="Mystery restaurant")
city = Location(name="Bikini Bottom", description="Underwater city")

Plot
plot = """
In a bustling underwater city, a sea sponge navigates daily life as a dedicated cook at a mysterious restaurant.
His eccentric friends include a carefree starfish and a grumpy squid, while a sneaky plankton constantly
schemes to steal a secret recipe. The show is a blend of humor, mystery, and vibrant characters.
"""

Show
underwater_show = Show(title="Underwater Mysteries", characters=[hero, friend, neighbor, villain],
locations=[restaurant, city], plot=plot)

Display
def display_show_info(show):
print(f"Title: {show.title}\n")
print("Characters:")
for char in show.characters:
print(f"- {char.name} ({char.species}): {char.role}")
print("\nLocations:")
for loc in show.locations:
print(f"- {loc.name}: {loc.description}")
print("\nPlot:")
print(show.plot)

display_show_info(underwater_show)