def mySqrt (n):
old=0
new=n/2
while abs(old-new)>1e-10 :
old=new
new=1/2*(old+n/old)
return new4 Functions
4.0.0.1 Sqrt 사용자 정의 함수 실습
mySqrt(3)1.7320508075688772
list_int=[1,2,3,4,5,6,7,8]
list_str=["1","2","3","4","5","6","7","8"]list(filter(lambda x:x,list_str))['1', '2', '3', '4', '5', '6', '7', '8']
list(filter(lambda x:x+"1",list_str))['1', '2', '3', '4', '5', '6', '7', '8']
bool("2")True
list(filter(lambda x:x,list_int))[]
list(filter(lambda x:bool(x-1),list_x))[2, 3, 4]
filter(lambda x:x-1,list_int)<filter at 0x1f5d235af10>