2022年1月4日 星期二

Python Built in Functions

 

FunctionDescription
abs()Returns the absolute value of a number
all()Returns True if all items in an iterable object are true
any()Returns True if any item in an iterable object is true
ascii()Returns a readable version of an object. Replaces none-ascii characters with escape character
bin()Returns the binary version of a number
bool()Returns the boolean value of the specified object
bytearray()Returns an array of bytes
bytes()Returns a bytes object
callable()Returns True if the specified object is callable, otherwise False
chr()Returns a character from the specified Unicode code.
classmethod()Converts a method into a class method
compile()Returns the specified source as an object, ready to be executed
complex()Returns a complex number
delattr()Deletes the specified attribute (property or method) from the specified object
dict()Returns a dictionary (Array)
dir()Returns a list of the specified object's properties and methods
divmod()Returns the quotient and the remainder when argument1 is divided by argument2
enumerate()Takes a collection (e.g. a tuple) and returns it as an enumerate object
eval()Evaluates and executes an expression
exec()Executes the specified code (or object)
filter()Use a filter function to exclude items in an iterable object
float()Returns a floating point number
format()Formats a specified value
frozenset()Returns a frozenset object
getattr()Returns the value of the specified attribute (property or method)
globals()Returns the current global symbol table as a dictionary
hasattr()Returns True if the specified object has the specified attribute (property/method)
hash()Returns the hash value of a specified object
help()Executes the built-in help system
hex()Converts a number into a hexadecimal value
id()Returns the id of an object
input()Allowing user input
int()Returns an integer number
isinstance()Returns True if a specified object is an instance of a specified object
issubclass()Returns True if a specified class is a subclass of a specified object
iter()Returns an iterator object
len()Returns the length of an object
list()Returns a list
locals()Returns an updated dictionary of the current local symbol table
map()Returns the specified iterator with the specified function applied to each item
max()Returns the largest item in an iterable
memoryview()Returns a memory view object
min()Returns the smallest item in an iterable
next()Returns the next item in an iterable
object()Returns a new object
oct()Converts a number into an octal
open()Opens a file and returns a file object
ord()Convert an integer representing the Unicode of the specified character
pow()Returns the value of x to the power of y
print()Prints to the standard output device
property()Gets, sets, deletes a property
range()Returns a sequence of numbers, starting from 0 and increments by 1 (by default)
repr()Returns a readable version of an object
reversed()Returns a reversed iterator
round()Rounds a numbers
set()Returns a new set object
setattr()Sets an attribute (property/method) of an object
slice()Returns a slice object
sorted()Returns a sorted list
staticmethod()Converts a method into a static method
str()Returns a string object
sum()Sums the items of an iterator
super()Returns an object that represents the parent class
tuple()Returns a tuple
type()Returns the type of an object
vars()Returns the __dict__ property of an object
zip()Returns an iterator, from two or more iterators

學Python可以做什麼:9個Python應用報你知

學Python可以做什麼:9個Python應用報你知
學Python可以做什麼

學Python可以做什麼:9個Python應用報你知

最後更新時間: 2021 年 10 月 12 日

我不是資工系、不是理工科、不是…,當你想學程式語言卻好像有好多條件不符的障礙,想學程式語言卻又猶豫不決,怕自己學不來,下定決心想投入學習後,卻又在茫茫的程式語言爆炸資訊當中,載浮載沉,不知道從哪開始著手。

對於沒有背景的程式語言學習者,Python是個很好的入門語言,而且應用也相當廣泛,本文將介紹9個Python應用面向,想快速閱讀的朋友,可以使用快速閱讀目錄點擊到你有興趣的地方閱讀。

為什麼選Python?

  • Python被稱為最容易上手、學習門檻低的程式語言:
    怎麼說呢? 因為Python屬於高階程式語言,跟人類習慣的語法比較接近,容易撰寫跟除錯,相對其他程式語言(如C語言)當然就容易學習許多。
  • Python容易上手,有利於培養對學習程式語言的興趣:
    瞭解自己對寫程式是不是有興趣,若有興趣,可以更深入專研Python,且從Python上學到的邏輯基礎,也可以讓我們更快的上手其他程式語言;而若只是被程式熱的風潮影響,對程式語言沒有興趣,Python讓你投入的成本與時間相對很少。
  • Python是全球最受歡迎的程式語言之一:
    從2021年9月TIOBE編程社區索引所列的程式語言受歡迎程度表來看,Python排名僅次於C語言,而且Python的應用多資源多、支援多,發展空間大、學習資源豐富此外大量的函式庫,讓工程師可以更快的完成工作。(函式就是一段程式,這段程式有名稱,並可以執行一些操作。)
  • 數據科學與人工智慧是未來科技發展的趨勢:
    數據科學與人工智慧這2個應用是Python的強項,也是Python近幾年來這麼熱門的原因,學會Python除了擁抱未來科技,也幫助自己的競爭力大加分。
 2021年9月TOIBE前10大熱門程式語言,Pyt
2021年9月TOIBE前10大熱門程式語言,Python位居第2

學Python可以做什麼?

瞭解Python的優點後,是不是開始對學Python有點心動,但還是存在一點點疑惑,就是:

  • Python究竟可以做什麼?
  • Python有哪些應用?
  • Python用途有哪些?

其實,我們天天會使用的搜尋引擎Google影音平台YoutubeNetflix社群平台Instagram雲端儲存平台dropbox甚至NASA 計算衛星軌道都有使用 Python

Python的應用其實相當廣泛,這邊我們列舉9個應用面向。

延伸閱讀-12個入門Python線上課程:讓你快速學會寫程式

延伸閱讀 -5本Python書推薦,強化你的程式語言觀念

網路爬蟲與擷取資訊

網路爬蟲是Python常見的應用,也是入門Python最常拿來做為學習成果的目標。

網路爬蟲是什麼意思呢?單就字面上的意思來看,就是我們設計出一個程式,派他到我們有興趣的地方(網頁)找尋我們所需要的資訊,利用程式去自動獲取網頁資訊的技術。

實務上的應用,例如google就是使用Python作為網路爬蟲工具,使搜尋引擎可以找到你需要的資料;比價網站如BigGo,主要也是運用Python來蒐集各個目標產品的價格與購買資訊。許多網站的資訊、社群平台的發言、按讚數蒐集,都可以運用Python設定條件來取得。

延伸閱讀 自學Python爬蟲課程-超過10堂線上課程教你爬蟲應用

下面這支影片,可以透由比較生動有趣的方式再來理解網路爬蟲是什麼?


數據分析與視覺化

資料分析處理是Python的強項,因為Python具有很完備生態環境,舉凡數據分析中會用到的分散式計算、資料視覺化、資料庫操作等功能,都有函式庫可以幫助工程師快速完成數據分析,並且以美觀、好閱讀的圖表呈現出來。

而分析後的數據就可以幫助我們優化業務流程、瞭解客戶、擬定廣告投放策略、提高投資效益,例如電商平臺就針對用戶評論數據建立數據庫,分析用戶的消費模式,擬定行銷活動、優化產品,來達到提高收益的目的。

下方簡短1分鐘的影片,讓我們快速瞭解數據分析應用,原來相關的應用早就在我們周遭了。


機器學習與人工智慧

人工智慧可說是Python如此熱門的原因,Python有許多函式庫可運用於人工智慧的開發,而且還具備高靈活度,讓工程師可以結合不同的程式語言,讓整體的演算呈現最有利的運作。

熱門機器學習框架,例如Google的TensorFlow 、Facebook 的 PyTorch ,都與 Python有很密切的關連性。

讓我們透由1個趣味的小動畫,帶我們簡單的理解AI人工智慧。


網站開發

Python有上百種網站開發框架,以Django這個框架為最大宗,其他如Flask、Pyramid 、web2py、bottle.py 也都是很受歡迎的框架。

網站開發框架是一個已經設定好的程式架構 ,開發者依照架構的規範來寫程式,有利加快程式開發速度、提升程式再利用及可讀性。

透由網站開發框架,Python讓網站開發變得更有效率,不過若學程式的目標在於開發網頁,HTML、CSS、JavaScript是目前開發網頁的主流,初學者可自行斟酌學習的方向。


遊戲開發

有許多業餘的遊戲開發愛好者,會以PyGame來開發遊戲。

但由於Python的執行效率不足以支應一款精緻的遊戲,如果學程式語言的目的為開發遊戲,建議使用Unity和C#。

不過假如只是想透過寫出一個小遊戲來幫助自己學會Python,會是滿有趣的小專案。點擊下方影片,看看pygame上熱度最高的小遊戲:Nelly’s Rooftop Garden是長怎樣。

pyweeks上最受歡迎的小遊戲:透由移動鐵塊或木塊使蒸汽凝結為水,完成澆花工作。

圖形使用者介面

使用Python內建的 Tkinter 函式庫,做出按鈕、文字方塊、下拉式選單等圖形使用者介面。


商業應用

企業資源管理系統(ERP)odooTryton 即使用Python來建置。

Source:odoo
Tryton
Tryton

影音應用

影音剪輯軟體PiTiVi是以Python做出來的。

Source:Pitivi

電腦輔助設計

免費的CAD 繪圖FreeCAD是所使用的程式語言為Python與C++,具有免費和開源特性,用戶可以利用Python擴充軟體功能。

Source:wiki.freecadweb.org

設定學習目標增強持續學習的動力

學習任何事情都是需要持之以恆地投入才會有成效,剛開始學習程式語言時,如果能設定好一個學習的目標,可以增強我們的學習動力,學習過程中也比較能夠有個概念,學成之後成果將是什麼,也比表較不容易因為迷失而忘了當初學習的初衷。

以上9個Python的應用介紹,提供給有興趣學習Python的初學者參考,想想學程式的目的是什麼?想利用軟體來發揮什麼功用呢?選1個有興趣的領域,就開始著手學習,努力地去達成目標!

延伸閱讀:

5本Python書推薦,強化你的程式語言觀念

12個入門Python線上課程:讓你快速學會寫程式

看不懂程式碼?免費「程式語言家教」在這裡!

Python觀念,從 = 開始

Python if 陳述句的基礎與操作

Python字串基礎與20種常見操作

Python串列(list) 基礎與23個常用操作

Python字典(dictionary)基礎與16種操作

Python正規表示式:不一定要會,但會了超省力

Python while 迴圈(loop)基本認識與3種操作

Python for 迴圈(loop)的基本認識與7種操作

Leave a Comment

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

Python 標準函式庫 (Standard Library

Python 標準函式庫 (Standard Library) — Python 3.12.0a3 說明文件 ...