跳到主要內容

Python Study (1) - Introduce Python

 

Why do I study Python  
    
     
Each program has advantage itself, why I study python program? This book(*1)
      give us several  advantages :

      1   Software quality : Python script is designed to be readable , reusable and
           maintainable.
      2   Developer productivity : We don't need to complie program.
      3.  Program portability :  It is portable and  run on any operating  system
      4.  Module :  many module is written in python
      5.  Easy : Easy to learn, easy to read, easy to maintain

User 
     Many companys adopt Python language to develop its products. such as :google,

      youtube, dropbox, google app engine...etc

What do python do          
         1. GUI 

         2. OS program
         3. Internet program
         4. Component Integration
         5, Database program


Python feature       
         1. Dynamic typing : you don't need to
declare a type or variable size in advance.
            Such as:  i = 0 ;
         2. Automatic memory management :  it   when the object is created
it can automatic create  and destroy

              object. python
         3. third-party utilities : developers  contribute many packages that is write in
             Python. To use these  save  your development time.
         4. easy to use : like human  syntax and simple read or write.
         5. free  :  It is free.

Download python             
              Download python install : https://www.python.org/downloads/

               Python 2.X  : it is a legacy.
               Python 3.X  : it is a evolution software and new features. such as: Unicode support.

               which version should I use : ref https://wiki.python.org/moin/Python2orPython3
             

       
    install

    Execute Python


 

  •  Python script execute          
               When the python code(.py) is executed first time, it will be into bytecode(.pyc).

                Bytecode is an implementation detail of the CPython interprete and low-level code.
                Bytecode makes execute faster than original source .
           
  • Python Virtual Machine(PVM)                  
             Python code is compiled to byte code(.pyc), PVM will execute the byte code.

              PVM is a engin of Python.



    • Setting variable environment
    1. Set your python environment variable
         
            Edit Path : C:\Python27\; C:\Python27\Scripts


        
         > python
     
        > ctrl + Z

      
        If you had installed many python versions, you can py -2 or  py -3 to switch   
         different  python version.

     
  •  Use IDLE
         1. Select IDLE , open Python Shell window    
     
          2. Execute python code
         


         3. To write python's script
        open New File.


        write a program

        Run Module or F5


        The script has executed and right to get answer
     
         

      
       
       
           
    Note:
           *1. Learning Python, 5th Edition, O'Reilly Media, ISBN:978-1-44935-573-9
  • 留言

    這個網誌中的熱門文章

    JavaBean 和POJO

    前言 今天介紹JavaBean和POJO的不同,這兩個名詞在JAVA文章常常被拿來使用以及討論。在JDK1.1時候釋出才有的一個標準架構,很多時候常常被搞混,所以我們特別開闢一章來加以討論。POJO規範在企業級應用已經廣大的被使用的規範。 解釋 POJO : 全名為Plain-old-Java-object,只需要繼承Object就可以,沒有特定規定,只要建立的類別有setter/getter方法都可以稱為POJO JavaBean: JavaBean通常用來封裝多個物件成為單獨物件使用,規範比較嚴格,規則如下 規則 說明 1 需要實作序列(Serializable/Externalizable) 2 不能有參數的建構子( no-arg constructor) 3 需要有公用setter/getter 4 屬性必須要私人(private) 5 屬於特定POJO規則 比較 所有的JavaBean都為POJO,但是所有的POJO不一定為JavaBean 都可以當作重複元件 都必須序列化 特性都為可用性、易用性和持久化使用 - 應用 由圖我們可以知道POJO在應用程式中,主要用來存取資料庫資料達到持久化的目的,並提供給商業邏輯流程處理使用。這種POJO的架構提供程式人員開發時的可以很有規則將資料封裝並加以使用。 範例1. JavaBean(以員工為實例) JavaBean建立員工物件,可以發現Employee物件建構子沒有任何參數,屬性為私有化並setter/getter的命名方式。 //實作序列化 public class Employee implements java.io.Serializable{ private int id; private String name; //無參數建構子 public Employee(){} //以下實作setter/getter public void setId(int id){this.id=id;} public int getId(){return id;} public void setName(String ...

    Python AI-問題集

    Python AI-問題集 問題集 Jupyter Notebook執行ipywidgets會出現kernel死掉的錯誤發生(The kernel appears to have died) 解決方法 (1) 根據log檔來判斷問題: 例如:log訊息出現OMP: Error #15: Initializing libiomp5.dylib, but found libiomp5.dylib already initialized. (2) 根據問題關鍵字找出問題所在: 利用google查詢所遭遇到的問題,例如我把上面的問題上google查詢可以找到這篇的解法 https://blog.csdn.net/bingjianIT/article/details/86182096 (3)實作解法: 我實作下面解法後,就可以順利執行手寫辨識的程式. //在Python宣告時加入 import os os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE" 參考 https://blog.csdn.net/bingjianIT/article/details/86182096

    淺談機器學習原理-Nonlinear Transform

    Nonlinear Transform 淺談機器學習原理-Nonlinear Transform Nonlinear Transform *通用能力 gerneralization : 就是將訓練好的模型,放到正式環境可以正常的運作,通常Linear Model的gerneralization會比較好,因為線性模型解決的問題比較單純。缺點是應用侷限比較大。 參考Chih-Chung Chang老師的範例:縣性與非線性分類範例 https://www.csie.ntu.edu.tw/~cjlin/libsvm/ 非線性問題 當如果今天假設要圈出裡面小圈圈的資料,我們就無法使用線性的模型,我們可以用非線性解像圈圈的方程式 s i g n ( − x 1 2 − x 2 2 + r ) sign(-x1^2-x2^2+r) s i g n ( − x 1 2 − x 2 2 + r ) 來解決,在演算法我們利用reduce來將不會的問題透過已知的問題來解決,所以在這個問題 我們將圈圈的方程式(非線性模型)reduce成線性模型來解決。 Reduce 方法論 我們調整圓形的方程式改為 z 0 z_0 z 0 ​ , z 1 z_1 z 1 ​ , z 2 z_2 z 2 ​ 來轉換線性方程式, { ( x n , y n ) } \{{(x_n,y_n)}\} { ( x n ​ , y n ​ ) } => { ( z n , y n ) } \{{(z_n,y_n)}\} { ( z n ​ , y n ​ ) } 在這空間資料中只要能找線,就可將不同的分類區分,圖中可以線性可以線去做分類。 透過向量方式來轉換成線性方程式 我們找到一個方式將非線性資料X透過向量轉換為Z後,希望透過線性方程式方式來學習,得到正解。 當我們Nonlinear transform轉換成線性方程式,當有新的資料進來我們無法使用invertiable(逆向工程)的方式去轉回非線...