Latest web development tutorials

Pythonは演習46、

Pythonの100リー Pythonの100リー

タイトル:出口が二乗場合、入力されたデジタル正方形、50未満を求めています。

プログラム解析:なし

ソースコード:

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

TRUE = 1
FALSE = 0
def SQ(x):
    return x * x
print '如果输入的数字小于 50,程序将停止运行。'
again = 1
while again:
    num = int(raw_input('Please input number'))
    print '运算结果为 %d' % (SQ(num))
    if num >= 50:
        again = TRUE
    else:
        again = FALSE

上の例の出力は、次のとおりです。

如果输入的数字小于 50,程序将停止运行。
Please input number300
运算结果为 90000
Please input number12
运算结果为 144

Pythonの100リー Pythonの100リー