Áã»ù´¡ÈëÃÅѧϰPython£¨10£©£ºº¯Êý
¼òµ¥µÄº¯Êý½éÉÜ
: #²»´ø²ÎÊýµÄ¼òµ¥º¯Êý print('ÕâÊÇÎÒ´´½¨µÄµÚÒ»¸öº¯Êý£¡') >>> myFirstFunc() #º¯Êýµ÷Óà ÕâÊÇÎÒ´´½¨µÄµÚÒ»¸öº¯Êý£¡ : #´«ÈëÒ»¸ö×Ö·û´®name,nameÊÇÐβΠprint("My name is " + name) #ʹÓÃÁË×Ö·û´®Æ´½Ó >>> mySecondFunc("Jessica") #"Jessics"ÊÇʵ²Î£¬µ÷ÓôøÐβεĺ¯ÊýʱҪдÈëʵ²Î My name is Jessica : (x+y) >>> result = myThirdFunc(1,2) #¿ÉÒÔ°Ñ·µ»ØÖµ¸³¸øÒ»¸ö±äÁ¿ >>> resultº¯Êý²ÎÊýÓÐÒÔϼ¸ÖÖÇé¿ö
1¡¢¹Ø¼ü×Ö²ÎÊý£¬¼´±äÁ¿Ãû
2¡¢Ä¬ÈϲÎÊý
,name = "LittleSeven"): print("The name of the " + pet+ " is " + name) >>> test2() #ÓÐĬÈϲÎÊýʱ£¬¿ÉÒÔ²»Ð´³ö²ÎÊýÖ±½Óµ÷Óà The name of the dog is LittleSeven >>> test2("cat","maomi") #Ò²¿ÉÒÔÖ±½Ó´«Èëʵ²Î£¬´Ëʱ»á¸²¸ÇĬÈϲÎÊý The name of the cat is maomi3¡¢ÊÕ¼¯²ÎÊý£º²ÎÊý¸öÊý¿É±ä
: #¸øÐβαäÁ¿ÃûÇ°¼ÓÒ»¸öÐǺţ¨*£©£¬¼´³ÉΪ¸öÊý¿É±äµÄÐβΠprint("The length of parameter is: " , len(params)) print("The first argument is: " , params[0]) >>> test3(2,3,"Hello",3.14) #²ÎÊý±»´ò°ü³ÉÔª×é The length of parameter is: 4 The first argument : #ÓÐÊÕ¼¯²ÎÊýÖ®ºó»¹¿ÉÒÔÓÐÆäËû²ÎÊý print("The length of parameter is: " , len(params)) print("The additive value is: " , addition) >>> test4(2,3,"Hello",3.14,addition = 7) #µ÷Óú¯Êýʱ£¬¹Ø¼ü×Ö²ÎÊý±ØÐëд³öÐβÎÃûÔÙ¸³Öµ£¬·ñÔò»á±»µ±×÷ÊÕ¼¯²ÎÊýµÄÒ»Ô±±»´ò°üµ½Ôª×éÖÐ The length of parameter is: 4 The additive value is: 7×îºóÔÙ½éÉÜϺ¯ÊýµÄ·µ»ØÖµ£¬PythonÖк¯Êý¿ÉÒÔ·µ»Ø¶à¸öÖµ£¬Ä¬ÈÏÊÇ·µ»ØÔª×é
: return (2,3.14,"Jessica") #ÒÔÔª×éÐÎʽ·µ»Ø¶à¸ö²ÎÊý >>> s = back() >>> s (2, 3.14, 'Jessica')Áã»ù´¡ÈëÃÅѧϰPython£¨9£©£ºÐòÁÐ
¶¥ 2 ²È 0
ÎÒµÄͬÀàÎÄÕÂ
²ÂÄãÔÚÕÒ
²é¿´ÆÀÂÛ
* ÒÔÉÏÓû§ÑÔÂÛÖ»´ú±íÆä¸öÈ˹۵㣬²»´ú±íCSDNÍøÕ¾µÄ¹Ûµã»òÁ¢³¡
¸öÈË×ÊÁÏ
qq_33256568
»ý·Ö£º165
ÎÄÕÂËÑË÷
ÎÄÕ·ÖÀà
ÎÄÕ´浵
ÔĶÁÅÅÐÐ
ÆÀÂÛÅÅÐÐ
¡¡