sqrt2 int input triggers AssertionErrorassumed as int not

Issue #2 new
Former user created an issue

If I try a simple mysqrt.sqrt2(2) triggers and assertion error from code: uwhpsc / lectures / lecture4 / mysqrt.py > line 17 assert x>0. and type(x) is float, "Unrecognized input" mysqrt.sqrt2(2,) works just find. I'm using Python version 2.7.5+

Comments (2)

  1. Randall J LeVeque repo owner

    Yes, it's written to expect a float but not an int. It could be improved by changing the assertion to

    assert x>0. and (type(x) in [float,int]), "Unrecognized input"
    
  2. Log in to comment