Last active
July 8, 2021 11:30
-
-
Save gangulymadhura/45b497f5b6b5a70cc675d7dcbf69f034 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DummyClass: | |
"""Class to print input text | |
Attributes: | |
------------ | |
text : string | |
""" | |
def __init__(self, text): | |
self.text = text | |
def check(self): | |
""" Checks if input is string and non-empty | |
Returns | |
------- | |
True if input is string and non-empty | |
Raises error otherwise | |
""" | |
# check if input is a string | |
if not isinstance(self.text, str): | |
raise TypeError("Expected a string") | |
# check if input is non-empty | |
elif len(self.text) <= 0: | |
raise ValueError("Expected a non-empty string") | |
return True | |
def print_text(self): | |
"""prints input text in lower case | |
Returns | |
------- | |
None | |
""" | |
if self.check(): | |
# convert string to lower case | |
self._text_lower() | |
self.text = "*****************\n"+self.text+"\n*****************\n" | |
print(self.text) | |
def _text_lower(self): | |
"""to convert text to lower case | |
Returns | |
------- | |
None | |
""" | |
self.text = self.text.lower() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment