Skip to content

Instantly share code, notes, and snippets.

@ybv
Last active August 29, 2015 14:07
Show Gist options
  • Save ybv/872b7caf00fbced18a55 to your computer and use it in GitHub Desktop.
Save ybv/872b7caf00fbced18a55 to your computer and use it in GitHub Desktop.
'''
python roundup
131 -> 200
999 -> 1000
'''
def roundUp(num):
val = (int(str(num)[0])+1)*pow(10,len(str(num))-1)
'''
python sqrt
49 -> 7.00000014127
10 -> 3.16227766518
'''
def sqroot(num,guess=1):
while not abs(guess*guess-num) < 0.001:
guess = (guess + (num/guess))/2.0
return guess
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment