Created
February 9, 2020 19:33
-
-
Save edenau/a25e86dfa6441351955aef530afbf9f1 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
def sum_of_squares(nums): | |
""" | |
Compute the sum of squares of a list of numbers. | |
Args: | |
nums (`list` of `int` or `float`): A `list` of numbers. | |
Returns: | |
ans (`int` or `float`): Sum of squares of `nums`. | |
Raises: | |
AssertionError: If `nums` contain elements that are not floats nor ints. | |
""" | |
try: | |
ans = sum([x**2 for x in nums]) | |
except: | |
raise AssertionError('Input should be a list of floats or ints.') | |
return ans | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment