Latest web development tutorials

Python 練習實例81

Python 100例 Python 100例

題目: 809*??=800*??+9*??+1其中??代表的兩位數,8*??的結果為兩位數,9*??的結果為3位數。 求??代表的兩位數,及809*??後的結果。

程序分析:無。

程序源代碼:

#!/usr/bin/python
# -*- coding: UTF-8 -*-

a = 809
for i in range(10,100):
    b = i * a + 1
    if b >= 1000 and b <= 10000 and 8 * i < 100 and 9 * i >= 100:
        print b,'/',i,' = 809 * ',i,' + ', b % i

以上實例輸出結果為:

9709 / 12  = 809 *  12  +  1

Python 100例 Python 100例