# You must make sure to run all cells in sequence using shift + enter or you might encounter errors
from pykubegrader.initialize import initialize_assignment

responses = initialize_assignment("11_what_we_do_in_the_shadows", "week_7", "lecturenotgraded", assignment_points = 20.0, assignment_tag = 'week7-lecturenotgraded')

# Initialize Otter
import otter
grader = otter.Notebook("11_what_we_do_in_the_shadows.ipynb")

๐Ÿ’ป๐Ÿฆ‡ What We Code in the Shadows ๐Ÿ’€๐Ÿ’ป#

The Vampire Council (yes, the same one from What We Do in the Shadows ๐Ÿฆ‡) has grown tired of inefficient blood-tracking methodsโ€”sticky notes on coffins and carved messages into castle walls just donโ€™t cut it anymore.

They need a modern Python-based blood registry to track the different vampire species in their coven and determine when itโ€™s safe to go outside. You, a newly turned vampire (congrats? ๐Ÿ˜ฌ), have been given the task of coding it.

๐ŸŽฏ Your Mission (If You Choose to Accept Itโ€ฆ You Donโ€™t Really Have a Choice)#

Implement a class hierarchy that properly represents different vampire types while enforcing ancient vampire laws using:

  • ๐Ÿฆด Abstract Classes (Because Some Things Should Never Be Instantiated)

  • ๐Ÿงช Static Methods (Because We Donโ€™t Do Unnecessary Object Creation)

  • ๐Ÿง› Multiple Inheritance (Because Real Vampires Have Layers)

๐Ÿ“ Coding Rules of the Vampire Council#

  1. Create an abstract class Vampire ๐Ÿฆ‡ with:

  • An abstract method feed(), which MUST be implemented by all subclasses.

  • A class attribute coven (a list) to keep track of all vampires.

  • A constructor that takes name and adds the vampire to coven.

  1. Create a mixin NightCreature ๐ŸŒ™ with:

  • A static method is_night(time: int) -> bool that returns True if itโ€™s nighttime (18-6), otherwise False. (Because burning alive is a huge inconvenience.)

  1. Create three vampire subclasses ๐Ÿง›:

  • Nosferatu ๐Ÿฆด: Creepy, silent, and way too old. Implements feed() and prints "Nosferatu {name} lurks in the basement and drinks ancient blood ๐Ÿฉธ."

  • FancyVampire ๐Ÿท: Think Laszlo and Nadjaโ€”elegant, dramatic, and refusing to eat peasant blood. Implements feed() and prints "Fancy Vampire {name} swirls a glass of Type O- ๐Ÿท and complains about peasant blood."

  • EnergyVampire ๐Ÿ”‹: Like Colin Robinson, these vampires donโ€™t drink bloodโ€”they drain life by boring people. Implements feed() and prints "Energy Vampire {name} starts a 2-hour lecture on tax law ๐Ÿ“„ and drains the room."

  • All vampires should inherit from Vampire and NightCreature.

  1. Test the system โœ…:

  • Create three vampires (Nosferatu("Petyr"), FancyVampire("Laszlo"), EnergyVampire("Colin Robinson")).

  • Call .feed() on each.

  • Check if is_night(20) and is_night(10) return the correct results.

  • Print the entire coven list.

๐Ÿ† Expected Output#

Nosferatu Petyr lurks in the basement and drinks ancient blood ๐Ÿฉธ.
Fancy Vampire Laszlo swirls a glass of Type O- ๐Ÿท and complains about peasant blood.
Energy Vampire Colin Robinson starts a 2-hour lecture on tax law ๐Ÿ“„ and drains the room.
True
False
['Petyr', 'Laszlo', 'Colin Robinson']
# Import from the abc module ABC and abstractmethod
...

# ๐Ÿฆ‡ Abstract base class for all vampires
# build the Vampire class as an abstract base class with an abstract method feed
...

    # define a class variable coven as an empty list
    ...

    # define an __init__ method that takes a name parameter
    # and sets the name attribute to the value of the name parameter
    # and appends the name to the coven list
    ...

    # define an abstract method feed
    ...


# ๐ŸŒ™ Mixin class to determine if it's night
# build the NightCreature class with a static method is_night that takes a time parameter
# and returns True if the time is between 18 and 06 (nighttime)
...

# ๐Ÿฆด Nosferatu: Creepy, terrifying, and socially awkward
# build the Nosferatu class that inherits from Vampire and NightCreature
# make the Nosferatu class feed method print a message: "Nosferatu {name} lurks in the basement and drinks ancient blood ๐Ÿฉธ."
...


# ๐Ÿท Fancy Vampire: Lives for drama and expensive blood
# build the FancyVampire class that inherits from Vampire and NightCreature
# make the FancyVampire class feed method print a message: "Fancy Vampire {name} swirls a glass of Type O- ๐Ÿท and complains about peasant blood.""
...

# ๐Ÿ”‹ Energy Vampire: The real horror
# Build the EnergyVampire class that inherits from Vampire and NightCreature
# make the EnergyVampire class feed method print a message: "Energy Vampire {name} starts a 2-hour lecture on tax law ๐Ÿ“„ and drains the room."
...

# โœ… Test cases
petyr = Nosferatu("Petyr")
laszlo = FancyVampire("Laszlo")
colin = EnergyVampire("Colin Robinson")

# Vampires feeding
petyr.feed()
laszlo.feed()
colin.feed()

# Checking night-time status
print(NightCreature.is_night(20))  # True ๐ŸŒ™
print(NightCreature.is_night(10))  # False โ˜€๏ธ

# Checking the coven
print(Vampire.coven)  # ['Petyr', 'Laszlo', 'Colin Robinson']
grader.check("what-we-do-in the-shadows")

Submitting Assignment#

Please run the following block of code using shift + enter to submit your assignment, you should see your score.

from pykubegrader.submit.submit_assignment import submit_assignment

submit_assignment("week7-lecturenotgraded", "11_what_we_do_in_the_shadows")