-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Expand file tree
/
Copy pathclasses_docstring.py
More file actions
33 lines (28 loc) · 894 Bytes
/
classes_docstring.py
File metadata and controls
33 lines (28 loc) · 894 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class Potion:
"""
Represents a magical potion composed of various ingredients.
Attributes
----------
name : str
The name of the potion.
ingredients : list of str
A list of ingredients used in the potion.
potency : int
The strength level of the potion.
Methods
-------
brew():
Completes the potion and sets its potency.
describe():
Returns a human-readable summary of the potion.
"""
def __init__(self, name, ingredients):
self.name = name
self.ingredients = ingredients
self.potency = 0
def brew(self):
"""Simulate brewing the potion by calculating potency."""
self.potency = len(self.ingredients) * 10
def describe(self):
"""Return a string describing the potion and its strength."""
return f"{self.name} (Potency: {self.potency})"