36
Giới thiệu ngôn ngữ lập trình Python Hoàng Nam Hải [email protected]

Introduction to python 20110917

Embed Size (px)

Citation preview

Page 1: Introduction to python   20110917

Giới thiệu ngôn ngữ lập trình Python

Hoàng Nam Hả[email protected]

Page 2: Introduction to python   20110917

5’ tự giới thiệu

Page 3: Introduction to python   20110917

Hoàng Nam Hải

• Master of Art in Business IT

• Coder/programmer: 17 năm

• Mobile application: 2 năm

• Founder & CEO của công ty

ManaTech (mana.vn)

• Chuyên sâu trong 3 lĩnh vực:

• Web Crawler

• P2P streaming

• J2ME application

• Language: Java 2năm, Python 2 năm,

C#6 năm , Vb.Net, Perl, Pascal ...

Page 4: Introduction to python   20110917

Ứng dụng Sóng VàngCung cấp thông tin dịch vụ, địa điểm thay thế cho cuốn danh bạ Những trang vàng.

Ngôn ngữ lập trình: C++Chạy trên các thiết bị sử dụng hệ điều hành SamSung Bada

Giải nhì cuộc thi lập trình Bada

Page 5: Introduction to python   20110917

Cổng thông tin OneApp cho Android

• Ngôn ngữ lập trình: Java• Chạy tốt với các thiết bị

Android cấu hình thấp

Page 6: Introduction to python   20110917

Ứng dụng Zing Me clientTruy cập nhiều tiện ích trên mạng xã hội Zing Me.

Ưu điểm của phần mềm: • Giao diện thân thiện• Tốc độ cao• Chi phí kết nối

(3G/GPRS) thấp• Tính năng đa dạng

• Ngôn ngữ lập trình: Java/J2ME

Page 7: Introduction to python   20110917

Ứng dụng World Cup 2010

Cung cấp mọi thông tin xoay quanh World Cup 2010: tin tức, lịch thi đấu, bảng xếp hạng, tường thuật trận đấu...

• Ngôn ngữ lập trình: Java/J2ME

• Chạy tốt trên các dòng máy điện thoại cấu hình thấp

Page 8: Introduction to python   20110917

5’ Khán giả tự giới thiệu

Page 9: Introduction to python   20110917

• Python, Java, C#, C++...• PHP, Javascript, Flash ...• Json, XML, CSS, Web service,

Html ...

Page 10: Introduction to python   20110917

Ngôn ngữ lập trình Python

1. Why?2. Tour? (Cưỡi ngựa xem

hoa)3. How to begin?

Page 11: Introduction to python   20110917

Why Python?Why not Java? C#? C++? PHP? ...Why not SQL? Oracle? ...

Why? Why? Why?

Page 12: Introduction to python   20110917

For fun For $,$

Page 13: Introduction to python   20110917

Dễ họcCấu trúc, cú pháp đơn giản

Thư viện nhiều, chất lượng tốtjson, http, xml, zlibimap, pop3, snmp, sqlite, mysqltwisted, django, cherrypy ...

Đa năngServer: Web app, chat server, mail

server, monitor service, các app tích hợp dịch vụ,

Client: Phần mềm GUI, nghiên cứu dữ liệu...

Code một tí là chạy được...

Page 14: Introduction to python   20110917

FreeĐa hệHiệu năng cao (high-perf)

Network, memory, serialize/deserializeHiệu quả cao

productivity, maintain, deploy

Page 15: Introduction to python   20110917

Ai dùng Python?Dự án nào dùng Python?

Page 16: Introduction to python   20110917

Web site: Google, Google App Engine, Youtube, Google Web search....System: NASA, IBM, HP, Intel, Cisco...Desktop: Dropbox, Miro playerMobile phone: Nokia, Microsoft (Windows CE)P2P: Bittorrent

Page 17: Introduction to python   20110917

Tour – Cưỡi ngựa xem hoa

Page 18: Introduction to python   20110917

http://python.org

Page 19: Introduction to python   20110917

http://docs.python.org

Page 20: Introduction to python   20110917

x = 34 - 23 # A comment. y = “Hello” # Another one. z = 3.45 if z == 3.45 or y == “Hello”: x = x + 1 y = y + “ World” # String concat. print x print y

Page 21: Introduction to python   20110917

1.Whitespace2.Multiple assignment3.Document string4.Sequence types, list comprehension5.Functions: define, default value,

order of args, used as data type6.Json, Send mail, Twisted, Cherrypy

Page 22: Introduction to python   20110917

Whitespace

Whitespace is meaningful in Python: especially indentation and placement of newlines.

• Use a newline to end a line of code. – Use \ when must go to next line prematurely.

• No braces { } to mark blocks of code in Python… Use consistent indentation instead. – The first line with less indentation is outside of the

block.– The first line with more indentation starts a nested

block

• Often a colon appears at the start of a new block. (E.g. for function and class definitions.)

Page 23: Introduction to python   20110917

Comment & document

• Start comments with # – the rest of line is ignored.• Can include a “documentation string” as the first line of any

new function or class that you define.• The development environment, debugger, and other tools

use it: it’s good style to include one.

def my_function(x, y): “““This is the docstring. This

function does blah blah blah.”””# The code would go here...

Page 24: Introduction to python   20110917

Multiple Assignment

• Một lúc có thể gán nhiều giá trị• Một hàm có thể trả về nhiều giá trị

Page 25: Introduction to python   20110917

Xử lý danh sách: dễ & nhanh

Page 26: Introduction to python   20110917

Xử lý danh sách: dễ & nhanh (2)

Page 27: Introduction to python   20110917

Xử lý danh sách: dễ & nhanh (3)

Page 28: Introduction to python   20110917

Xử lý danh sách: dễ & nhanh (4)

Page 29: Introduction to python   20110917

Dùng Function như một object

Page 30: Introduction to python   20110917

Download và cài đặt thư viện

Page 31: Introduction to python   20110917

Easy install

Example 1. Install a package by name, searching PyPI for the latest version, and automatically downloading, building, and installing it:easy_install SQLObject

Example 2. Install or upgrade a package by name and version by finding links on a given "download page":easy_install -f http://pythonpaste.org/package_index.html SQLObject

Example 3. Download a source distribution from a specified URL, automatically building and installing it:easy_install http://example.com/path/to/MyPackage-1.2.3.tgz

Page 32: Introduction to python   20110917

JSON

Page 33: Introduction to python   20110917

Gmail Send

Page 34: Introduction to python   20110917

Tài liệu tự học

Page 35: Introduction to python   20110917
Page 36: Introduction to python   20110917

Q&A

Hoàng Nam Hải

http://mana.vnEmail: [email protected]