note 5 二分法求平方根,素数,回文数
生活随笔
收集整理的這篇文章主要介紹了
note 5 二分法求平方根,素数,回文数
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
+二分法求平方根
x = float(raw_input('Enter the number')) low = 0 high = x guess = (low + high ) / 2 if x < 0:print 'Number Error' while abs(guess**2 - x) > 1e-5:if guess**2 < x:low = guesselse:high = guess guess = (low + high) / 2 print 'The root of is',guess+素數
前50個
+回文數
num = 12321 num_p = 0 num_temp = numwhile num != 0:num_p = num_p * 10 + num % 10num /= 10if num_temp == num_p:print 'OK' else:print 'NO'轉載于:https://www.cnblogs.com/OceanF/p/10773239.html
總結
以上是生活随笔為你收集整理的note 5 二分法求平方根,素数,回文数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 接口测试工具Postman(转)
- 下一篇: css实现文本超出两行隐藏