以前在學校對於程式實在沒興趣以至於學得哩哩落落的

現在開始重新學習發現這個Funtion和method的差別的概念實在太重要了

第一至少你得知道語法,不然連程式都寫不出來呢

function(函数)語法 method(方法)語法
def 函数名(參數):
action
 
函数名(參數)

 

 

string.count(value, start, end)

 

 

 

 

def my_function(fname):
  print(fname + " Refsnes")

my_function("Emil")
my_function("Tobias")
my_function("Linus")

txt = "I love apples, apple are my favorite fruit"

y = txt.count("apple")

print(y)

Emil Refsnes
Tobias Refsnes
Linus Refsnes
2
 

 

 

 

Coursera 筆記如下:

from University of Michigan->Introduction to Data Science in Python->Week 1-> Python Functions

Screen Shot 0032-09-04 at 15.30.52.png

Screen Shot 0032-09-04 at 15.38.30.png

 
 
 
 
 
 

arrow
arrow

    莎 發表在 痞客邦 留言(0) 人氣()