Add a Static Validator
Beginner · Write the code · from Python @classmethod vs @staticmethod: When to Use Each
From the lesson: Python @classmethod vs @staticmethod: When to Use Each
Imagine a company with three kinds of employees. Regular employees work on their own tasks (they need to know about themselves). Managers can hire new employees for the whole department (they need to know about the department).
Read the lessonCreate a Password class with a value attribute. Add a @staticmethod called is_strong that takes a password string and returns True if it has 8 or more characters, False otherwise.
Print the result of Password.is_strong('abc') and Password.is_strong('securepass123').
# Create your Password class here
More Classmethod and Staticmethod exercises
- Create a Factory MethodBeginner
- Predict the Method OutputIntermediate
- Fix the Factory MethodIntermediate
- Build a Temperature ConverterAdvanced
All Python exercises · 50 practice problems · Object-Oriented Programming quiz