也许最有名的是if语句。例如: x = int(raw_input("Please enter an integer: ")) Please enter an integer: 42 if x 0: ... x = 0 ... print 'Negative changed to zero' ... elif x == 0: ... print 'Zero' .. ...
当然,我们可以使用 Python 完成比二加二更复杂的任务。例如,我们可以写一个生成菲波那契子序列的程序,如下所示: # Fibonacci series: ... # the sum of two elements defines the next ... a, b = 0, 1 while b ...