The third day of learning pyton

Small knowledge function: Note that the above two functions involve calling

#function
 
 
1. First, you must learn to write code that Luo and see where is reusable
2. The code is then converted to the repeated use of a parameter, brought into the function
 
# Function body
 
DEF funcName ([param]): 
    executable 
    [retrue]

# Writing array

= G [ ' noodles ' , ' ham ' , ' beer ' ]

# Can do if you do not have too much trouble if

Learning the code: The main function is to call

# Simple lottery Code

 
       
def zr():
    a = input ( "Please enter a name")
    b = ['zr1']
    if a in b:
        print ( 'Congratulations')
    else:
        print ( 'I'm sorry, you pass and awards, but do not be discouraged')
zr()

 # Commodity purchase, small case is very important ********

#商品 
'''
def Check_Goods(g):
    G = ['泡面','火腿','啤酒']
    if g in G:
        Address()
    else:
        return False
def Check_Information(name,phone,Addr):
    is_ok = True
    if name =="" or name ==" ":
        is_ok = False
    if len(phone) !=11:
        is_ok = False
    if Addr not in ['北京','山东']:
        is_ok = False
    return is_ok
def Address():
    name = input('Name:')
    phone = input('Phone:')
    Addr = input('Addr:')
    res = Check_Information(name,phone,Addr)
    if res:
        Note()
    False return 
DEF Note (): 
    Print ( 'immediate shipment') 

DEF gaozhi (): 
    Print ( 'Welcome') 
    G = the INPUT ( 'goods:') 
    Check_Goods (G) 
gaozhi () 
# User Registration 
def yonghujiance (yonghuming , mi, Shouji): 
    is_ok = True 
    IF yonghuming == "" or yonghuming == "": 
        Print ( 'user name you entered is not lawful') 
    IF len (mi)> 11: 
        Print ( 'less you enter the password to 11 ') 
    IF len (Shouji) = 11:! 
        Print (' you enter the phone number of illegal ') 
    return is_ok 
DEF yonghu (): 
    yonghuming = the iNPUT (' the Name: ') 
    mima = the iNPUT (' NIMA: ' ) 
    shoujihao = INPUT ( 'Phone:') 
    RES = Check_Information (yonghuming, MIMA, shoujihao)
yanzhengma DEF: 
    Pass 
DEF gaozhi (): 
    Print ( 'Welcome')

gaozhi () '' '

 # User Registration

DEF   yonghujiance (yonghuming, mi, Shouji): 
    is_ok = True
     IF yonghuming == ""  or yonghuming == "  " :
         Print ( ' user name you entered is not lawful ' )
     IF len (mi)> 11 :
         Print ( ' you enter the password of less than 11 ' )
     IF len (Shouji) = 11! :
         Print ( ' you enter the phone number of illegal ' )
     return is_ok
 DEF   yonghu (): 
    yonghuming = the iNPUT ( 'Name: ' ) 
    MIMA = INPUT ( ' NIMA: ' ) 
    shoujihao = INPUT ( ' Phone: ' ) 
    RES = Check_Information (yonghuming, MIMA, shoujihao)
 DEF   yanzhengma:
     Pass 
DEF gaozhi ():
     Print ( ' Welcome ' ) 

gaozhi ( )

 

 

 

Guess you like

Origin www.cnblogs.com/zrxuexi/p/11285518.html