Python includes exercises 46
Title: seeking input digital square, less than 50 if the exit squaring.
Program Analysis: None
Source Code:
#!/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
The above example output is:
如果输入的数字小于 50,程序将停止运行。 Please input number300 运算结果为 90000 Please input number12 运算结果为 144