class Cal(object):
def add_num_and_double(self, x, y):
"""Add and double
>>> c = Cal()
>>> c.add_num_and_double(1,1)
4
>>> c.add_num_and_double('1', '1')
Traceback (most recent call last):
...
ValueError
"""
if type(x) is not int or type(y) is not int:
raise ValueError
result = x + y
result *= 2
return result
if __name__ == '__main__':
import doctest
doctest.testmod()
More than 3 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme