A user interface contains two types of user input controls: TextInput, which accepts all characters and NumericInput, which accepts only digits.
Implement the class TextInput that contains:
- Method add(self, character) - adds the given character to the current value
- Method get_value(self) - returns the current value
Implement the class NumericInput that:
- Inherits TextInput
- Overrides the add method so that each non-numeric character is ignored
For example, the following code should output "10":
input = NumericInput() input.add("1") input.add("a") input.add("0") print(input.get_value())
Duration: 15 min
Score DistributionNot enough data for chart.
Would you like to see our other questions?
We have 1000+ premium hand-crafted questions for 160+ job skills and 20+ coding languages. We prefer questions with small samples of actual work over academic problems or brain teasers.
On the blog
Since we're all biased and we use incorrect proxies, why not just outsource hiring to experts or recruitment agencies? After all, they've been screening people for many years, so they must know how to do it right?
Not really. I was surprised to discover that many experts...