Python 练习实例12

题目:输入一个奇数,然后判断最少几个 9 除于该数的结果为整数。

# -*- coding: UTF-8 -*-
 
if __name__ == '__main__':
    zi = int(raw_input('输入一个数字:\n'))
    n1 = 1
    c9 = 1
    m9 = 9
    sum = 9
    while n1 != 0:
        if sum % zi == 0:
            n1 = 0
        else:
            m9 *= 10
            sum += m9
            c9 += 1
    print '%d 个 9 可以被 %d 整除 : %d' % (c9,zi,sum)
    r = sum / zi
    print '%d / %d = %d' % (sum,zi,r)

https://www.runoob.com/python/python-exercise-example85.html

上一篇:java语言基础之关键字2(abstract、interface、implements、instanceof)


下一篇:极光客户互动云java post请求