wenwen
wenwen

探索網路世界和進入區塊鏈的過程或許很平凡,但我就是想分享給大家,若能幫助到有需要幫助的人,那就更好了。 有幫到你的話,記得按下方拍手圖,不需花你任何金錢,免費註冊Liker ID,就可對我化讚為賞:https://button.like.co/willie5068

011第八章 FUNCTIONS

今天看 Netflix 無照律師 看到 第六季第三集,哇!還有三季還沒看(共九季)。這是我今天這麼晚PO 文的主要原因。

💛20230111晨讀感言:

💔不得不說,整理每日的Email來信,若不小心,就會花掉你不少時間,所以,我發展出最簡單的方式,就是刪信,每隔兩三天就把信箱保持清空。但是,就算是刪信,只要一不注意,你就會因為某些吸引你的內容,讓你就像掉入黑洞一樣一直沉浸於其中,除非達到「奇異點」並再經歷像宇宙大爆炸的過程後,才會從中解脫出來。《[潘羅斯的奇異點定理](https://pb.ps-taiwan.org/modules/news/article.php?storyid=72)》

💔今天看書前,我做了刪信這個「多餘」的動作,然後就看到吸引我的一篇文章 《 [5 Best Apps to Organize Your Life (That Aren’t Notion)](https://medium.com/my-learning-journal/5-best-apps-to-organize-your-life-that-arent-notion-3f428042dc3c)》,其實,重點在於 That Aren’t Notion 這個字眼。當然,也讓我審視並打算看完本書《python crash course》後再重組我「 第二大腦」 所使用的筆記軟體成員。

💔我喜歡程式中 function 的概念,因為,你只要寫一次,就可以在你有需求的時候 呼叫並使用之。其實,在你一開始接觸程式且還不知道 function 或 method 之前,就已經在使用它了,像是 print 功能,換言之,瞭解 function 和 method 及 class 三者間的差異和關連的課題,將會從這章開始。

💔終於瞭解中文翻譯的缺點(語意表達不足)了,因為 Arguments and Parameters 的中文翻譯都是「參數」,但在 英文世界裡,中文所翻譯的 「參數」,會以它所在處而有不同的稱呼:即定義Function 時,Funciotn括號內的 參數 稱 Parameters ,而呼叫 Funciotn時,Function括號內的 參數 稱 Arguments 。

💔接上,傳送 Arguments 有兩種方式,一種稱為 Positional Arguments ,另一種稱為 keyword arguments ,我比較偏好 keyword arguments 的傳送方式。

💔從上,瞭解 在function 之外 的變數(暫稱為「外部變數」),可以在 function 內 被 modified ,但是,離開了 function 之後,「外部變數」又恢復成 它原本所被賦予的值 。另外,在 記錄程式時,也發現 在Markdown 語法中將 code區塊 縮圖 的新技巧。

💔目前 發現可以 經由 function內部 來 modified 在 function 程式區塊 以外 的 List 和 Dictionary ,而這也正好補足 「外部變數」 無法 在 function 內 被modified。

💛晨讀摘要:

💚131 Arguments and Parameters: The variable username in the definition of greet_user() is an example of a _parameter_, a piece of information the function needs to do its job. The value ‘jesse’ in greet_user(‘jesse’) is an example of an _argument_. An argument is a piece of information that is passed from a function call to a function.

💚136 **Positional Arguments** When you call a function, Python must match each argument in the function call with a parameter in the function definition. The simplest way to do this is based on the order of the arguments provided. Values matched up this way are called _positional arguments_.

💚135 When you use default values, any parameter with a default value needs to be listed after all the parameters that don’t have default values. This allows Python to continue interpreting positional arguments correctly.

💚137 A function doesn’t always have to display its output directly. Instead, it can process some data and then return a value or set of values. The value the function returns is called a _return value_. The return statement takes a value from inside a function and sends it back to the line that called the function.

💚138 Making an Argument Optional : You can use default values to make an argument optional.

💚 140 Returning a Dictionary : You can think of None as a placeholder value. In conditional tests, None evaluates to False.

💚139 Modifying a List in a Function :When you pass a list to a function, the function can modify the list. Any changes made to the list inside the function’s body are permanent, allowing you to work efficiently even when you’re dealing with large amounts of data.

💚148 Mixing Positional and Arbitrary Arguments : If you want a function to accept several different kinds of arguments, the parameter that accepts an arbitrary number of arguments must be placed last in the function definition. 但是,如果有 設定值keyword的話,設定值要擺在更後面。

💚150 Importing an Entire Module: To start importing functions, we first need to create a module. A _module_ is a file ending in _.py_ that contains the code you want to import into your program.

💚154 If you specify a default value for a parameter, no spaces should be used on either side of the equal sign.The same convention should be used for keyword arguments in function calls.

from :《python crash course》

CC BY-NC-ND 2.0 版权声明

喜欢我的文章吗?
别忘了给点支持与赞赏,让我知道创作的路上有你陪伴。

加载中…
加载中…

发布评论