def comp(x,y):
if x < y:
print x, "is less than ",y # incdent 2 space is OK, not must TAB
elif x > y:
print x, "is greater than ",y
else:
print x, "and", y, "are equal"
comp(1,2);
comp(3,1);
comp(1,1);
x = -100;
if 0 < x < 200:
print "x is between 0~200"
else:
print "x is not in scale"
# recursion
def countdown(n):
if n == 0:
print "Blastoff!"
else:
print n
countdown(n-1)
countdown(5);
# keyboard input
print "===========input==========="
# print "Please input:"
inputthing = raw_input("What is your name?");
print inputthing
speed=input("What is the train speed?"); # integer
print speed Results:
===========def func===========
First Line.
Second Line
10 is even
11 is odd
1 is less than 2
3 is greater than 1
1 and 1 are equal
x is not in scale
5
4
3
2
1
Blastoff!
===========input===========
What is your name?xiahouzuoxin
xiahouzuoxin
What is the train speed?100
100