2009-04-13 三項式 python 2.5からは三項式つかえます。 num = 7 tmp = str(num) + 'は偶数です。' if(num % 2 == 0) else str(num) + 'は奇数です。' print tmp