2017.8.31 Codecademy

練習1

  1. def a function called cube that takes an argument called number.
  2. make that function return the cube of that number (i.e. that number multiplied by itself and multiplied by itself once again).
  3. def a second function called by_three that takes an argument called number.
  4. if that number is divisible by 3, by_three should call cube(number) and return its result.
  5. otherwise, by_three should return False.
def cube(number):
   return number * number * number

def by_three(number):
   if number % 3 == 0:
     return cube(number)
 else:
     return False

print(cube(2))
print(by_three(3))
print(by_three(4))

8
27
False

閱讀更多»

程式語言自學之路

從小時候的單機遊戲、國中開始接觸線上遊戲,到現在每天都在玩各種不同手機遊戲,不同時期、不同平台,一直以來都覺得能寫出一個程式、app或遊戲是一件很酷的事,2017年7月開始出社會後漸漸覺得,資訊科技一日千里,將來的趨勢會越來越需要資訊相關的技能,也因為本身對這方面很有興趣,8月初決定自學程式語言,搜尋了許多資料,決定以外行者最好入門的Python開始。

之前看到有前輩建議自學者可以寫部落格,記錄自己的學習過程以及解決問題的過程,當時還沒有實踐,但一個月後發現,很多學過的語法沒有複習或是應用,真的很容易遺忘,或是遇到相同問題又再次卡關之類的,於是這個部落格就誕生了,雖然不知道能持續多久,但希望自己的自學之路能因此更加順遂有動力。