Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def square_root(number):
- if number < 0 :
- raise Exception("Cannot find the square root of negetive number")
- root = 1
- while(root**2 <= number):
- root += 1
- return root-1
- def square_root_test():
- # read assert syntax
- assert 2 == square_root(4)
- assert 4 == square_root(17)
- try:
- square_root(-20)
- except Exeption as e:
- pass
- else:
- assert False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement