python(学习之路一)

'''
Created on 2013-5-3

@author: lixingle
'''
#输出的练习
length=3
width=4;
area=length*width
print(area)
print('area is :',area)

#for loop练习
for i in range(1,5):

#range的步长为1。如果我们为range提供第
#三个数,那么它将成为步长。例如,range(1,5,2)给出[1,3]。记住,range 向上 延伸到第二个


    print(i)
else :
    print ('for is over')
#if 的练习
'''
number = 23 

myresult=True
while myresult:
    guess=int(input('请输入一个整数: '))
    if guess==number:
        print('ok')
        myresult=False
    elif guess>number:
        print("大了")
    else :
        print ('小了')
'''        
#函数定义
def getMax(a,b): 
    '''
    get max of two number
    '''
    global x
    x=3
    print(x) 
    if a>b:
        print (a)
    elif a<=b:
        print (b)
#函数调用      
 
x=10

getMax(12,6)
print (x)        

原文地址:https://www.cnblogs.com/lixingle/p/3313063.html