582
@ Programming Language 2013 Python 郭軒(KuoE0[email protected] KuoE0.ch

Python @NCKU CSIE

Embed Size (px)

DESCRIPTION

National Cheng Kung University 2013 Programming Language Talk About Python

Citation preview

Page 3: Python @NCKU CSIE

What is Python?

Page 4: Python @NCKU CSIE

What is Python?

a programming language

Page 5: Python @NCKU CSIE

What is Python?

easy to Read

easy to Learneasy to Write

a programming language

Page 6: Python @NCKU CSIE

PositionMay 2013

PositionMay 2012

Delta in Position Programming Language

1 1 = C2 2 = Java3 4 ↑ Objective-C4 3 ↓ C++5 5 = C#6 6 = PHP7 7 = Visual Basic8 8 = Python9 9 = Perl10 11 ↑ Ruby

http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html

Top Language in TIOBE

Page 7: Python @NCKU CSIE

Javascript

Ruby

Java

Python

Shell

PHP

C

C++

Perl

Objective-C

0% 5% 10% 15% 20% 25%

3%

4%

5%

6%

7%

8%

8%

8%

12%

21%

Top Languages in Github

https://github.com/languages

Page 8: Python @NCKU CSIE

Javascript

Ruby

Java

Python

Shell

PHP

C

C++

Perl

Objective-C

0% 5% 10% 15% 20% 25%

3%

4%

5%

6%

7%

8%

8%

8%

12%

21%

Top Languages in Github

https://github.com/languages

Page 9: Python @NCKU CSIE

What does the logo mean?

Page 10: Python @NCKU CSIE

界 Kingdom 動物界 Animalia

⾨門 Phylum 脊索動物⾨門 Chordata

綱 Class 爬蟲科 Reptilia

⺫⽬目 Order 有鱗⺫⽬目 Squamata

科 Family 蟒科 Pythonidae

屬 Genus 蟒屬 Python

Page 13: Python @NCKU CSIE

More About Python...

Page 14: Python @NCKU CSIE

More About Python...

Interpreted Language

Do not need to compile!

Page 15: Python @NCKU CSIE

Compiled Language

compiler execute

Page 16: Python @NCKU CSIE

Interpreted Language

execute

But, interpret in execution time.

And, it would be slow...

Page 17: Python @NCKU CSIE

More About Python...

Object-Oriented Language

Everything in Python is object!

Page 18: Python @NCKU CSIE

number

function

string

listObject

Page 19: Python @NCKU CSIE

number

function

string

listObject

Page 20: Python @NCKU CSIE

overloading

polymorphism

inheritance

multiple inheritance

Page 21: Python @NCKU CSIE

More About Python...

Imperative Programming

Generic Programming

Functional Programming

Page 22: Python @NCKU CSIE

Philosophy

Page 23: Python @NCKU CSIE

There should be one—and preferably only one—obvious way to do it.

Philosophy

Page 24: Python @NCKU CSIE

There should be one—and preferably only one—obvious way to do it.

Philosophy

There should be one—and preferably only one—obvious way to do it.

Page 25: Python @NCKU CSIE

$

Zen of Python

Page 26: Python @NCKU CSIE

$ $ python -ic “”

Zen of Python

Page 27: Python @NCKU CSIE

$ $ python -ic “”$ python -ic “”>>>

Zen of Python

Page 28: Python @NCKU CSIE

$ $ python -ic “”$ python -ic “”>>>$ python -ic “”>>> import this

Zen of Python

Page 29: Python @NCKU CSIE

$ $ python -ic “”$ python -ic “”>>>$ python -ic “”>>> import this$ python -ic “”>>> import thisThe Zen of Python, by Tim Peters

Beautiful is better than ugly.Explicit is better than implicit.Simple is better than complex.Complex is better than complicated.Flat is better than nested.Sparse is better than dense.Readability counts.Special cases aren't special enough to

>>> import thisThe Zen of Python, by Tim Peters

Beautiful is better than ugly.Explicit is better than implicit.Simple is better than complex.Complex is better than complicated.Flat is better than nested.Sparse is better than dense.Readability counts.Special cases aren't special enough to break the rules.

The Zen of Python, by Tim Peters

Beautiful is better than ugly.Explicit is better than implicit.Simple is better than complex.Complex is better than complicated.Flat is better than nested.Sparse is better than dense.Readability counts.Special cases aren't special enough to break the rules.Although practicality beats purity.

Beautiful is better than ugly.Explicit is better than implicit.Simple is better than complex.Complex is better than complicated.Flat is better than nested.Sparse is better than dense.Readability counts.Special cases aren't special enough to break the rules.Although practicality beats purity.Errors should never pass silently.

Beautiful is better than ugly.Explicit is better than implicit.Simple is better than complex.Complex is better than complicated.Flat is better than nested.Sparse is better than dense.Readability counts.Special cases aren't special enough to break the rules.Although practicality beats purity.Errors should never pass silently.Unless explicitly silenced.

Explicit is better than implicit.Simple is better than complex.Complex is better than complicated.Flat is better than nested.Sparse is better than dense.Readability counts.Special cases aren't special enough to break the rules.Although practicality beats purity.Errors should never pass silently.Unless explicitly silenced.In the face of ambiguity, refuse the

Simple is better than complex.Complex is better than complicated.Flat is better than nested.Sparse is better than dense.Readability counts.Special cases aren't special enough to break the rules.Although practicality beats purity.Errors should never pass silently.Unless explicitly silenced.In the face of ambiguity, refuse the temptation to guess.

Complex is better than complicated.Flat is better than nested.Sparse is better than dense.Readability counts.Special cases aren't special enough to break the rules.Although practicality beats purity.Errors should never pass silently.Unless explicitly silenced.In the face of ambiguity, refuse the temptation to guess.There should be one-- and preferably only

Flat is better than nested.Sparse is better than dense.Readability counts.Special cases aren't special enough to break the rules.Although practicality beats purity.Errors should never pass silently.Unless explicitly silenced.In the face of ambiguity, refuse the temptation to guess.There should be one-- and preferably only one --obvious way to do it.

Sparse is better than dense.Readability counts.Special cases aren't special enough to break the rules.Although practicality beats purity.Errors should never pass silently.Unless explicitly silenced.In the face of ambiguity, refuse the temptation to guess.There should be one-- and preferably only one --obvious way to do it.Although that way may not be obvious at

Readability counts.Special cases aren't special enough to break the rules.Although practicality beats purity.Errors should never pass silently.Unless explicitly silenced.In the face of ambiguity, refuse the temptation to guess.There should be one-- and preferably only one --obvious way to do it.Although that way may not be obvious at first unless you're Dutch.

Special cases aren't special enough to break the rules.Although practicality beats purity.Errors should never pass silently.Unless explicitly silenced.In the face of ambiguity, refuse the temptation to guess.There should be one-- and preferably only one --obvious way to do it.Although that way may not be obvious at first unless you're Dutch.Now is better than never.

break the rules.Although practicality beats purity.Errors should never pass silently.Unless explicitly silenced.In the face of ambiguity, refuse the temptation to guess.There should be one-- and preferably only one --obvious way to do it.Although that way may not be obvious at first unless you're Dutch.Now is better than never.Although never is often better than *right*

Although practicality beats purity.Errors should never pass silently.Unless explicitly silenced.In the face of ambiguity, refuse the temptation to guess.There should be one-- and preferably only one --obvious way to do it.Although that way may not be obvious at first unless you're Dutch.Now is better than never.Although never is often better than *right* now.

Errors should never pass silently.Unless explicitly silenced.In the face of ambiguity, refuse the temptation to guess.There should be one-- and preferably only one --obvious way to do it.Although that way may not be obvious at first unless you're Dutch.Now is better than never.Although never is often better than *right* now.If the implementation is hard to explain,

Unless explicitly silenced.In the face of ambiguity, refuse the temptation to guess.There should be one-- and preferably only one --obvious way to do it.Although that way may not be obvious at first unless you're Dutch.Now is better than never.Although never is often better than *right* now.If the implementation is hard to explain, it's a bad idea.

In the face of ambiguity, refuse the temptation to guess.There should be one-- and preferably only one --obvious way to do it.Although that way may not be obvious at first unless you're Dutch.Now is better than never.Although never is often better than *right* now.If the implementation is hard to explain, it's a bad idea.If the implementation is easy to explain,

temptation to guess.There should be one-- and preferably only one --obvious way to do it.Although that way may not be obvious at first unless you're Dutch.Now is better than never.Although never is often better than *right* now.If the implementation is hard to explain, it's a bad idea.If the implementation is easy to explain, it may be a good idea.

There should be one-- and preferably only one --obvious way to do it.Although that way may not be obvious at first unless you're Dutch.Now is better than never.Although never is often better than *right* now.If the implementation is hard to explain, it's a bad idea.If the implementation is easy to explain, it may be a good idea.Namespaces are one honking great idea --

one --obvious way to do it.Although that way may not be obvious at first unless you're Dutch.Now is better than never.Although never is often better than *right* now.If the implementation is hard to explain, it's a bad idea.If the implementation is easy to explain, it may be a good idea.Namespaces are one honking great idea -- let's do more of those!

one --obvious way to do it.Although that way may not be obvious at first unless you're Dutch.Now is better than never.Although never is often better than *right* now.If the implementation is hard to explain, it's a bad idea.If the implementation is easy to explain, it may be a good idea.Namespaces are one honking great idea -- let's do more of those!

Although that way may not be obvious at first unless you're Dutch.Now is better than never.Although never is often better than *right* now.If the implementation is hard to explain, it's a bad idea.If the implementation is easy to explain, it may be a good idea.Namespaces are one honking great idea -- let's do more of those!>>>

Zen of Python

Page 30: Python @NCKU CSIE

Current Situation

Page 31: Python @NCKU CSIE

Current Situation

Python 2.x Python 3.x

Page 32: Python @NCKU CSIE

Current Situation

Python 2.x Python 3.x

Coexist!

Page 33: Python @NCKU CSIE

Current Situation

Python 2.x Python 3.x

Coexist!

Page 34: Python @NCKU CSIE

Current Situation

Python 2.x Python 3.x

Coexist!

backwards-incompatible

Page 35: Python @NCKU CSIE

Python 2.x Python 3.x

2.7.x is the latest version under development

more 3-party library 2to3.py

built-in on many OS more supported unicode

the past in someday the future in someday

Page 36: Python @NCKU CSIE

http://www.ibm.com/developerworks/cn/linux/l-python3-1/

Python 3 的新特性

Page 37: Python @NCKU CSIE

Python 2.x

Page 38: Python @NCKU CSIE

Python 2.xToday, Let’s Talk About

Page 39: Python @NCKU CSIE

Environment

Page 40: Python @NCKU CSIE

Environment

For Unix-like OS User,

Python 2.x is Built-in!

Page 41: Python @NCKU CSIE

Environment

For Windows User,

Download Fromhttp://www.python.org/download/

if you want to launch Python in command line, add the path of Python binary file into PATH variable.

Page 42: Python @NCKU CSIE

$

Check Version of Python

Page 43: Python @NCKU CSIE

$

Check Version of Python$ python --version

Page 44: Python @NCKU CSIE

$

Check Version of Python$ python --version$ python --versionPython 2.7.5

Page 45: Python @NCKU CSIE

$

Check Version of Python$ python --version$ python --versionPython 2.7.5

2.7.5 is released on May 15, 2013

Page 46: Python @NCKU CSIE

$

Check Version of Python

Page 47: Python @NCKU CSIE

$ $ python

Check Version of Python

Page 48: Python @NCKU CSIE

$ $ python$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>>

Check Version of Python

Page 49: Python @NCKU CSIE

$ $ python$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>>

Check Version of Python

Page 50: Python @NCKU CSIE

$

Interactive Shell

Page 51: Python @NCKU CSIE

$ $ python

Interactive Shell

Page 52: Python @NCKU CSIE

$ $ python$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>>

Interactive Shell

Page 53: Python @NCKU CSIE

$ $ python$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>>

Interactive Shell

prompt

Page 54: Python @NCKU CSIE

$ $ python$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>>

Interactive Shell

prompt

means that your turn!

Page 55: Python @NCKU CSIE

$

Interactive Shell

Page 56: Python @NCKU CSIE

$$ python

Interactive Shell

Page 57: Python @NCKU CSIE

$$ python$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>>

Interactive Shell

Page 58: Python @NCKU CSIE

$$ python$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 3

Interactive Shell

Page 59: Python @NCKU CSIE

$$ python$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 3

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>>

Interactive Shell

Page 60: Python @NCKU CSIE

$$ python$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 3

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”

Interactive Shell

Page 61: Python @NCKU CSIE

$$ python$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 3

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>>

Interactive Shell

Page 62: Python @NCKU CSIE

$$ python$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 3

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100

Interactive Shell

Page 63: Python @NCKU CSIE

$$ python$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 3

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100

Python 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>>

Interactive Shell

Page 64: Python @NCKU CSIE

$$ python$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 3

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100

Python 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>>

Python 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200

Interactive Shell

Page 65: Python @NCKU CSIE

$$ python$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 3

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100

Python 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>>

Python 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200

23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>>

Interactive Shell

Page 66: Python @NCKU CSIE

$$ python$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 3

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100

Python 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>>

Python 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200

23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>>

23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y

Interactive Shell

Page 67: Python @NCKU CSIE

$$ python$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 3

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100

Python 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>>

Python 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200

23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>>

23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y

(clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y300>>>

Interactive Shell

Page 68: Python @NCKU CSIE

$$ python$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 3

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100

Python 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>>

Python 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200

23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>>

23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y

(clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y300>>>

(clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y300>>> for i in range(5):

Interactive Shell

Page 69: Python @NCKU CSIE

$$ python$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 3

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100

Python 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>>

Python 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200

23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>>

23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y

(clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y300>>>

(clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y300>>> for i in range(5):

Type "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y300>>> for i in range(5):...

Interactive Shell

Page 70: Python @NCKU CSIE

$$ python$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 3

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100

Python 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>>

Python 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200

23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>>

23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y

(clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y300>>>

(clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y300>>> for i in range(5):

Type "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y300>>> for i in range(5):...

Type "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y300>>> for i in range(5):... print i

Interactive Shell

Page 71: Python @NCKU CSIE

$$ python$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 3

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100

Python 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>>

Python 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200

23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>>

23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y

(clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y300>>>

(clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y300>>> for i in range(5):

Type "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y300>>> for i in range(5):...

Type "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y300>>> for i in range(5):... print i

"license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y300>>> for i in range(5):... print i...

Interactive Shell

Page 72: Python @NCKU CSIE

$$ python$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 3

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100

Python 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>>

Python 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200

23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>>

23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y

(clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y300>>>

(clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y300>>> for i in range(5):

Type "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y300>>> for i in range(5):...

Type "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y300>>> for i in range(5):... print i

"license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y300>>> for i in range(5):... print i...

>>> y = 200>>> x + y300>>> for i in range(5):... print i...01234>>>

Interactive Shell

Page 73: Python @NCKU CSIE

$$ python$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 3

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100

Python 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>>

Python 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200

23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>>

23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y

(clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y300>>>

(clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y300>>> for i in range(5):

Type "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y300>>> for i in range(5):...

Type "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y300>>> for i in range(5):... print i

"license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y300>>> for i in range(5):... print i...

>>> y = 200>>> x + y300>>> for i in range(5):... print i...01234>>>

>>> y = 200>>> x + y300>>> for i in range(5):... print i...01234>>> exit()

Interactive Shell

Page 74: Python @NCKU CSIE

$$ python$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 3

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>>

$ pythonPython 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100

Python 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>>

Python 2.7.5 (default, May 20 2013, 23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200

23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>>

23:41:46) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y

(clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y300>>>

(clang-425.0.28)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y300>>> for i in range(5):

Type "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y300>>> for i in range(5):...

Type "help", "copyright", "credits" or "license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y300>>> for i in range(5):... print i

"license" for more information.>>> 1 + 2 + 36>>> “Hello World”‘Hello World’>>> x = 100>>> y = 200>>> x + y300>>> for i in range(5):... print i...

>>> y = 200>>> x + y300>>> for i in range(5):... print i...01234>>>

>>> y = 200>>> x + y300>>> for i in range(5):... print i...01234>>> exit()

>>> x + y300>>> for i in range(5):... print i...01234>>> exit()$

Interactive Shell

Page 75: Python @NCKU CSIE

Hello World!

Page 76: Python @NCKU CSIE

Hello World!

if __name__ == “__main__”: print “Hello World!”

helloworld.py

Page 77: Python @NCKU CSIE

$

Hello World!

Page 78: Python @NCKU CSIE

$

Hello World!$ python helloworld.py

Page 79: Python @NCKU CSIE

$

Hello World!$ python helloworld.py$ python helloworld.pyHello World!$

Page 80: Python @NCKU CSIE

A Python Code

Page 81: Python @NCKU CSIE

A Python Codedef mul(x, y): ret = x * y return ret

for i in range(10)[2:]: for j in range(10)[1:]: print "{0} x {1} = {2}".format(i, j, mul(i, j))

9x9table.py

Page 82: Python @NCKU CSIE

script languagedef mul(x, y): ret = x * y return ret

for i in range(10)[2:]: for j in range(10)[1:]: print "{0} x {1} = {2}".format(i, j, mul(i, j))

no specified entry point

Page 83: Python @NCKU CSIE

$

script language

Page 84: Python @NCKU CSIE

$

script language$ python 9x9table.py

Page 85: Python @NCKU CSIE

$

script language$ python 9x9table.py$ python 9x9table.py2 x 1 = 22 x 2 = 42 x 3 = 62 x 4 = 82 x 5 = 102 x 6 = 122 x 7 = 142 x 8 = 162 x 9 = 183 x 1 = 33 x 2 = 63 x 3 = 9

2 x 1 = 22 x 2 = 42 x 3 = 62 x 4 = 82 x 5 = 102 x 6 = 122 x 7 = 142 x 8 = 162 x 9 = 183 x 1 = 33 x 2 = 63 x 3 = 93 x 4 = 12

2 x 2 = 42 x 3 = 62 x 4 = 82 x 5 = 102 x 6 = 122 x 7 = 142 x 8 = 162 x 9 = 183 x 1 = 33 x 2 = 63 x 3 = 93 x 4 = 123 x 5 = 15

2 x 3 = 62 x 4 = 82 x 5 = 102 x 6 = 122 x 7 = 142 x 8 = 162 x 9 = 183 x 1 = 33 x 2 = 63 x 3 = 93 x 4 = 123 x 5 = 153 x 6 = 18

2 x 4 = 82 x 5 = 102 x 6 = 122 x 7 = 142 x 8 = 162 x 9 = 183 x 1 = 33 x 2 = 63 x 3 = 93 x 4 = 123 x 5 = 153 x 6 = 183 x 7 = 21

2 x 5 = 102 x 6 = 122 x 7 = 142 x 8 = 162 x 9 = 183 x 1 = 33 x 2 = 63 x 3 = 93 x 4 = 123 x 5 = 153 x 6 = 183 x 7 = 213 x 8 = 24

2 x 6 = 122 x 7 = 142 x 8 = 162 x 9 = 183 x 1 = 33 x 2 = 63 x 3 = 93 x 4 = 123 x 5 = 153 x 6 = 183 x 7 = 213 x 8 = 243 x 9 = 27

2 x 7 = 142 x 8 = 162 x 9 = 183 x 1 = 33 x 2 = 63 x 3 = 93 x 4 = 123 x 5 = 153 x 6 = 183 x 7 = 213 x 8 = 243 x 9 = 274 x 1 = 4

2 x 8 = 162 x 9 = 183 x 1 = 33 x 2 = 63 x 3 = 93 x 4 = 123 x 5 = 153 x 6 = 183 x 7 = 213 x 8 = 243 x 9 = 274 x 1 = 44 x 2 = 8

2 x 9 = 183 x 1 = 33 x 2 = 63 x 3 = 93 x 4 = 123 x 5 = 153 x 6 = 183 x 7 = 213 x 8 = 243 x 9 = 274 x 1 = 44 x 2 = 84 x 3 = 12

3 x 1 = 33 x 2 = 63 x 3 = 93 x 4 = 123 x 5 = 153 x 6 = 183 x 7 = 213 x 8 = 243 x 9 = 274 x 1 = 44 x 2 = 84 x 3 = 124 x 4 = 16

3 x 2 = 63 x 3 = 93 x 4 = 123 x 5 = 153 x 6 = 183 x 7 = 213 x 8 = 243 x 9 = 274 x 1 = 44 x 2 = 84 x 3 = 124 x 4 = 164 x 5 = 20

3 x 3 = 93 x 4 = 123 x 5 = 153 x 6 = 183 x 7 = 213 x 8 = 243 x 9 = 274 x 1 = 44 x 2 = 84 x 3 = 124 x 4 = 164 x 5 = 204 x 6 = 24

3 x 4 = 123 x 5 = 153 x 6 = 183 x 7 = 213 x 8 = 243 x 9 = 274 x 1 = 44 x 2 = 84 x 3 = 124 x 4 = 164 x 5 = 204 x 6 = 244 x 7 = 28

3 x 5 = 153 x 6 = 183 x 7 = 213 x 8 = 243 x 9 = 274 x 1 = 44 x 2 = 84 x 3 = 124 x 4 = 164 x 5 = 204 x 6 = 244 x 7 = 284 x 8 = 32

3 x 6 = 183 x 7 = 213 x 8 = 243 x 9 = 274 x 1 = 44 x 2 = 84 x 3 = 124 x 4 = 164 x 5 = 204 x 6 = 244 x 7 = 284 x 8 = 324 x 9 = 36

3 x 7 = 213 x 8 = 243 x 9 = 274 x 1 = 44 x 2 = 84 x 3 = 124 x 4 = 164 x 5 = 204 x 6 = 244 x 7 = 284 x 8 = 324 x 9 = 365 x 1 = 5

3 x 8 = 243 x 9 = 274 x 1 = 44 x 2 = 84 x 3 = 124 x 4 = 164 x 5 = 204 x 6 = 244 x 7 = 284 x 8 = 324 x 9 = 365 x 1 = 55 x 2 = 10

3 x 9 = 274 x 1 = 44 x 2 = 84 x 3 = 124 x 4 = 164 x 5 = 204 x 6 = 244 x 7 = 284 x 8 = 324 x 9 = 365 x 1 = 55 x 2 = 105 x 3 = 15

4 x 1 = 44 x 2 = 84 x 3 = 124 x 4 = 164 x 5 = 204 x 6 = 244 x 7 = 284 x 8 = 324 x 9 = 365 x 1 = 55 x 2 = 105 x 3 = 155 x 4 = 20

4 x 2 = 84 x 3 = 124 x 4 = 164 x 5 = 204 x 6 = 244 x 7 = 284 x 8 = 324 x 9 = 365 x 1 = 55 x 2 = 105 x 3 = 155 x 4 = 205 x 5 = 25

4 x 3 = 124 x 4 = 164 x 5 = 204 x 6 = 244 x 7 = 284 x 8 = 324 x 9 = 365 x 1 = 55 x 2 = 105 x 3 = 155 x 4 = 205 x 5 = 255 x 6 = 30

4 x 4 = 164 x 5 = 204 x 6 = 244 x 7 = 284 x 8 = 324 x 9 = 365 x 1 = 55 x 2 = 105 x 3 = 155 x 4 = 205 x 5 = 255 x 6 = 305 x 7 = 35

4 x 5 = 204 x 6 = 244 x 7 = 284 x 8 = 324 x 9 = 365 x 1 = 55 x 2 = 105 x 3 = 155 x 4 = 205 x 5 = 255 x 6 = 305 x 7 = 355 x 8 = 40

4 x 6 = 244 x 7 = 284 x 8 = 324 x 9 = 365 x 1 = 55 x 2 = 105 x 3 = 155 x 4 = 205 x 5 = 255 x 6 = 305 x 7 = 355 x 8 = 405 x 9 = 45

4 x 7 = 284 x 8 = 324 x 9 = 365 x 1 = 55 x 2 = 105 x 3 = 155 x 4 = 205 x 5 = 255 x 6 = 305 x 7 = 355 x 8 = 405 x 9 = 456 x 1 = 6

4 x 8 = 324 x 9 = 365 x 1 = 55 x 2 = 105 x 3 = 155 x 4 = 205 x 5 = 255 x 6 = 305 x 7 = 355 x 8 = 405 x 9 = 456 x 1 = 66 x 2 = 12

4 x 9 = 365 x 1 = 55 x 2 = 105 x 3 = 155 x 4 = 205 x 5 = 255 x 6 = 305 x 7 = 355 x 8 = 405 x 9 = 456 x 1 = 66 x 2 = 126 x 3 = 18

5 x 1 = 55 x 2 = 105 x 3 = 155 x 4 = 205 x 5 = 255 x 6 = 305 x 7 = 355 x 8 = 405 x 9 = 456 x 1 = 66 x 2 = 126 x 3 = 186 x 4 = 24

5 x 2 = 105 x 3 = 155 x 4 = 205 x 5 = 255 x 6 = 305 x 7 = 355 x 8 = 405 x 9 = 456 x 1 = 66 x 2 = 126 x 3 = 186 x 4 = 246 x 5 = 30

5 x 3 = 155 x 4 = 205 x 5 = 255 x 6 = 305 x 7 = 355 x 8 = 405 x 9 = 456 x 1 = 66 x 2 = 126 x 3 = 186 x 4 = 246 x 5 = 306 x 6 = 36

5 x 4 = 205 x 5 = 255 x 6 = 305 x 7 = 355 x 8 = 405 x 9 = 456 x 1 = 66 x 2 = 126 x 3 = 186 x 4 = 246 x 5 = 306 x 6 = 366 x 7 = 42

5 x 5 = 255 x 6 = 305 x 7 = 355 x 8 = 405 x 9 = 456 x 1 = 66 x 2 = 126 x 3 = 186 x 4 = 246 x 5 = 306 x 6 = 366 x 7 = 426 x 8 = 48

5 x 6 = 305 x 7 = 355 x 8 = 405 x 9 = 456 x 1 = 66 x 2 = 126 x 3 = 186 x 4 = 246 x 5 = 306 x 6 = 366 x 7 = 426 x 8 = 486 x 9 = 54

5 x 7 = 355 x 8 = 405 x 9 = 456 x 1 = 66 x 2 = 126 x 3 = 186 x 4 = 246 x 5 = 306 x 6 = 366 x 7 = 426 x 8 = 486 x 9 = 547 x 1 = 7

5 x 8 = 405 x 9 = 456 x 1 = 66 x 2 = 126 x 3 = 186 x 4 = 246 x 5 = 306 x 6 = 366 x 7 = 426 x 8 = 486 x 9 = 547 x 1 = 77 x 2 = 14

5 x 9 = 456 x 1 = 66 x 2 = 126 x 3 = 186 x 4 = 246 x 5 = 306 x 6 = 366 x 7 = 426 x 8 = 486 x 9 = 547 x 1 = 77 x 2 = 147 x 3 = 21

6 x 1 = 66 x 2 = 126 x 3 = 186 x 4 = 246 x 5 = 306 x 6 = 366 x 7 = 426 x 8 = 486 x 9 = 547 x 1 = 77 x 2 = 147 x 3 = 217 x 4 = 28

6 x 2 = 126 x 3 = 186 x 4 = 246 x 5 = 306 x 6 = 366 x 7 = 426 x 8 = 486 x 9 = 547 x 1 = 77 x 2 = 147 x 3 = 217 x 4 = 287 x 5 = 35

6 x 3 = 186 x 4 = 246 x 5 = 306 x 6 = 366 x 7 = 426 x 8 = 486 x 9 = 547 x 1 = 77 x 2 = 147 x 3 = 217 x 4 = 287 x 5 = 357 x 6 = 42

6 x 4 = 246 x 5 = 306 x 6 = 366 x 7 = 426 x 8 = 486 x 9 = 547 x 1 = 77 x 2 = 147 x 3 = 217 x 4 = 287 x 5 = 357 x 6 = 427 x 7 = 49

6 x 5 = 306 x 6 = 366 x 7 = 426 x 8 = 486 x 9 = 547 x 1 = 77 x 2 = 147 x 3 = 217 x 4 = 287 x 5 = 357 x 6 = 427 x 7 = 497 x 8 = 56

6 x 6 = 366 x 7 = 426 x 8 = 486 x 9 = 547 x 1 = 77 x 2 = 147 x 3 = 217 x 4 = 287 x 5 = 357 x 6 = 427 x 7 = 497 x 8 = 567 x 9 = 63

6 x 7 = 426 x 8 = 486 x 9 = 547 x 1 = 77 x 2 = 147 x 3 = 217 x 4 = 287 x 5 = 357 x 6 = 427 x 7 = 497 x 8 = 567 x 9 = 638 x 1 = 8

6 x 8 = 486 x 9 = 547 x 1 = 77 x 2 = 147 x 3 = 217 x 4 = 287 x 5 = 357 x 6 = 427 x 7 = 497 x 8 = 567 x 9 = 638 x 1 = 88 x 2 = 16

6 x 9 = 547 x 1 = 77 x 2 = 147 x 3 = 217 x 4 = 287 x 5 = 357 x 6 = 427 x 7 = 497 x 8 = 567 x 9 = 638 x 1 = 88 x 2 = 168 x 3 = 24

7 x 1 = 77 x 2 = 147 x 3 = 217 x 4 = 287 x 5 = 357 x 6 = 427 x 7 = 497 x 8 = 567 x 9 = 638 x 1 = 88 x 2 = 168 x 3 = 248 x 4 = 32

7 x 2 = 147 x 3 = 217 x 4 = 287 x 5 = 357 x 6 = 427 x 7 = 497 x 8 = 567 x 9 = 638 x 1 = 88 x 2 = 168 x 3 = 248 x 4 = 328 x 5 = 40

7 x 3 = 217 x 4 = 287 x 5 = 357 x 6 = 427 x 7 = 497 x 8 = 567 x 9 = 638 x 1 = 88 x 2 = 168 x 3 = 248 x 4 = 328 x 5 = 408 x 6 = 48

7 x 4 = 287 x 5 = 357 x 6 = 427 x 7 = 497 x 8 = 567 x 9 = 638 x 1 = 88 x 2 = 168 x 3 = 248 x 4 = 328 x 5 = 408 x 6 = 488 x 7 = 56

7 x 5 = 357 x 6 = 427 x 7 = 497 x 8 = 567 x 9 = 638 x 1 = 88 x 2 = 168 x 3 = 248 x 4 = 328 x 5 = 408 x 6 = 488 x 7 = 568 x 8 = 64

7 x 6 = 427 x 7 = 497 x 8 = 567 x 9 = 638 x 1 = 88 x 2 = 168 x 3 = 248 x 4 = 328 x 5 = 408 x 6 = 488 x 7 = 568 x 8 = 648 x 9 = 72

7 x 7 = 497 x 8 = 567 x 9 = 638 x 1 = 88 x 2 = 168 x 3 = 248 x 4 = 328 x 5 = 408 x 6 = 488 x 7 = 568 x 8 = 648 x 9 = 729 x 1 = 9

7 x 8 = 567 x 9 = 638 x 1 = 88 x 2 = 168 x 3 = 248 x 4 = 328 x 5 = 408 x 6 = 488 x 7 = 568 x 8 = 648 x 9 = 729 x 1 = 99 x 2 = 18

7 x 9 = 638 x 1 = 88 x 2 = 168 x 3 = 248 x 4 = 328 x 5 = 408 x 6 = 488 x 7 = 568 x 8 = 648 x 9 = 729 x 1 = 99 x 2 = 189 x 3 = 27

8 x 1 = 88 x 2 = 168 x 3 = 248 x 4 = 328 x 5 = 408 x 6 = 488 x 7 = 568 x 8 = 648 x 9 = 729 x 1 = 99 x 2 = 189 x 3 = 279 x 4 = 36

8 x 2 = 168 x 3 = 248 x 4 = 328 x 5 = 408 x 6 = 488 x 7 = 568 x 8 = 648 x 9 = 729 x 1 = 99 x 2 = 189 x 3 = 279 x 4 = 369 x 5 = 45

8 x 3 = 248 x 4 = 328 x 5 = 408 x 6 = 488 x 7 = 568 x 8 = 648 x 9 = 729 x 1 = 99 x 2 = 189 x 3 = 279 x 4 = 369 x 5 = 459 x 6 = 54

8 x 4 = 328 x 5 = 408 x 6 = 488 x 7 = 568 x 8 = 648 x 9 = 729 x 1 = 99 x 2 = 189 x 3 = 279 x 4 = 369 x 5 = 459 x 6 = 549 x 7 = 63

8 x 5 = 408 x 6 = 488 x 7 = 568 x 8 = 648 x 9 = 729 x 1 = 99 x 2 = 189 x 3 = 279 x 4 = 369 x 5 = 459 x 6 = 549 x 7 = 639 x 8 = 72

8 x 6 = 488 x 7 = 568 x 8 = 648 x 9 = 729 x 1 = 99 x 2 = 189 x 3 = 279 x 4 = 369 x 5 = 459 x 6 = 549 x 7 = 639 x 8 = 729 x 9 = 81

8 x 7 = 568 x 8 = 648 x 9 = 729 x 1 = 99 x 2 = 189 x 3 = 279 x 4 = 369 x 5 = 459 x 6 = 549 x 7 = 639 x 8 = 729 x 9 = 81$

Page 86: Python @NCKU CSIE

If you need a main function as entry point,

if __name__ == “__main__”: print “Hello World!”

Page 87: Python @NCKU CSIE

If you need a main function as entry point,

if __name__ == “__main__”: print “Hello World!”

Page 88: Python @NCKU CSIE

If you need a main function as entry point,

if __name__ == “__main__”: print “Hello World!”

and write all statements after it.

Page 89: Python @NCKU CSIE

def mul(x, y): ret = x * y return ret

for i in range(10)[2:]: for j in range(10)[1:]: print "{0} x {1} = {2}".format(i, j, mul(i, j))

variable

can be used without declaration

Page 90: Python @NCKU CSIE

def mul(x, y): ret = x * y return ret

for i in range(10)[2:]: for j in range(10)[1:]: print "{0} x {1} = {2}".format(i, j, mul(i, j))

variabledef mul(x, y): ret = x * y return ret

for i in range(10)[2:]: for j in range(10)[1:]: print "{0} x {1} = {2}".format(i, j, mul(i, j))

can be used without declaration

Page 91: Python @NCKU CSIE

def mul(x, y): ret = x * y return ret

for i in range(10)[2:]: for j in range(10)[1:]: print "{0} x {1} = {2}".format(i, j, mul(i, j))

scope

use whitespace to identify scope

Page 92: Python @NCKU CSIE

def mul(x, y): ret = x * y return ret

for i in range(10)[2:]: for j in range(10)[1:]: print "{0} x {1} = {2}".format(i, j, mul(i, j))

scopedef mul(x, y): ret = x * y return ret

for i in range(10)[2:]: for j in range(10)[1:]: print "{0} x {1} = {2}".format(i, j, mul(i, j))

use whitespace to identify scope

Page 93: Python @NCKU CSIE

You can use

to identify scopes.

Page 94: Python @NCKU CSIE

You can useone space

two spaces

three spaces

four spaces

lots of spaces

to identify scopes.

Page 95: Python @NCKU CSIE

You can useone space

two spaces

three spaces

four spaces

lots of spaces

one tab

two tabs

three tabs

four tabs

lots of tabs

to identify scopes.

Page 96: Python @NCKU CSIE

But, you should unify the style!

Page 97: Python @NCKU CSIE

Built-in Data Type

Page 98: Python @NCKU CSIE

Null

None>>>

Page 99: Python @NCKU CSIE

Null

None>>>>>> None

Page 100: Python @NCKU CSIE

Null

None>>>>>> None>>> None>>>

Page 101: Python @NCKU CSIE

Boolean

TrueFalse

>>>

Page 102: Python @NCKU CSIE

Boolean

TrueFalse

>>> >>> 1 == 1

Page 103: Python @NCKU CSIE

Boolean

TrueFalse

>>> >>> 1 == 1>>> 1 == 1True>>>

Page 104: Python @NCKU CSIE

Boolean

TrueFalse

>>> >>> 1 == 1>>> 1 == 1True>>>

>>> 1 == 1True>>> 1 != 1

Page 105: Python @NCKU CSIE

Boolean

TrueFalse

>>> >>> 1 == 1>>> 1 == 1True>>>

>>> 1 == 1True>>> 1 != 1

>>> 1 == 1True>>> 1 != 1False>>>

Page 106: Python @NCKU CSIE

Boolean

TrueFalse

>>> >>> 1 == 1>>> 1 == 1True>>>

>>> 1 == 1True>>> 1 != 1

>>> 1 == 1True>>> 1 != 1False>>>

>>> 1 == 1True>>> 1 != 1False>>> True

Page 107: Python @NCKU CSIE

Boolean

TrueFalse

>>> >>> 1 == 1>>> 1 == 1True>>>

>>> 1 == 1True>>> 1 != 1

>>> 1 == 1True>>> 1 != 1False>>>

>>> 1 == 1True>>> 1 != 1False>>> True

>>> 1 == 1True>>> 1 != 1False>>> TrueTrue>>>

Page 108: Python @NCKU CSIE

Boolean

TrueFalse

>>> >>> 1 == 1>>> 1 == 1True>>>

>>> 1 == 1True>>> 1 != 1

>>> 1 == 1True>>> 1 != 1False>>>

>>> 1 == 1True>>> 1 != 1False>>> True

>>> 1 == 1True>>> 1 != 1False>>> TrueTrue>>>

>>> 1 == 1True>>> 1 != 1False>>> TrueTrue>>> False

Page 109: Python @NCKU CSIE

Boolean

TrueFalse

>>> >>> 1 == 1>>> 1 == 1True>>>

>>> 1 == 1True>>> 1 != 1

>>> 1 == 1True>>> 1 != 1False>>>

>>> 1 == 1True>>> 1 != 1False>>> True

>>> 1 == 1True>>> 1 != 1False>>> TrueTrue>>>

>>> 1 == 1True>>> 1 != 1False>>> TrueTrue>>> False

True>>> 1 != 1False>>> TrueTrue>>> FalseFalse>>>

Page 110: Python @NCKU CSIE

Boolean

TrueFalse

>>>

Page 111: Python @NCKU CSIE

Boolean

TrueFalse

upper case>>>

Page 112: Python @NCKU CSIE

Boolean

TrueFalse

upper case>>> >>> true

Page 113: Python @NCKU CSIE

Boolean

TrueFalse

upper case>>> >>> true>>> trueTraceback (most recent call last): File "<input>", line 1, in <module>NameError: name 'true' is not defined>>>

Page 114: Python @NCKU CSIE

Initialization / Conversion

TrueFalse

>>>

Page 115: Python @NCKU CSIE

Initialization / Conversion

TrueFalse

>>> >>> bool(1)

Page 116: Python @NCKU CSIE

Initialization / Conversion

TrueFalse

>>> >>> bool(1)>>> bool(1)True>>>

Page 117: Python @NCKU CSIE

Initialization / Conversion

TrueFalse

>>> >>> bool(1)>>> bool(1)True>>>

>>> bool(1)True>>> bool(True)

Page 118: Python @NCKU CSIE

Initialization / Conversion

TrueFalse

>>> >>> bool(1)>>> bool(1)True>>>

>>> bool(1)True>>> bool(True)

>>> bool(1)True>>> bool(True)True>>>

Page 119: Python @NCKU CSIE

Initialization / Conversion

TrueFalse

>>> >>> bool(1)>>> bool(1)True>>>

>>> bool(1)True>>> bool(True)

>>> bool(1)True>>> bool(True)True>>>

>>> bool(1)True>>> bool(True)True>>> bool()

Page 120: Python @NCKU CSIE

Initialization / Conversion

TrueFalse

>>> >>> bool(1)>>> bool(1)True>>>

>>> bool(1)True>>> bool(True)

>>> bool(1)True>>> bool(True)True>>>

>>> bool(1)True>>> bool(True)True>>> bool()

>>> bool(1)True>>> bool(True)True>>> bool()False>>>

Page 121: Python @NCKU CSIE

Logical Operators

and and

or or

not not

>>>

Page 122: Python @NCKU CSIE

Logical Operators

and and

or or

not not

>>> >>> (1 == 1) and True

Page 123: Python @NCKU CSIE

Logical Operators

and and

or or

not not

>>> >>> (1 == 1) and True>>> (1 == 1) and TrueTrue>>>

Page 124: Python @NCKU CSIE

Logical Operators

and and

or or

not not

>>> >>> (1 == 1) and True>>> (1 == 1) and TrueTrue>>>

>>> (1 == 1) and TrueTrue>>> (1 == 1) or False

Page 125: Python @NCKU CSIE

Logical Operators

and and

or or

not not

>>> >>> (1 == 1) and True>>> (1 == 1) and TrueTrue>>>

>>> (1 == 1) and TrueTrue>>> (1 == 1) or False

>>> (1 == 1) and TrueTrue>>> (1 == 1) or FalseTrue>>>

Page 126: Python @NCKU CSIE

Logical Operators

and and

or or

not not

>>> >>> (1 == 1) and True>>> (1 == 1) and TrueTrue>>>

>>> (1 == 1) and TrueTrue>>> (1 == 1) or False

>>> (1 == 1) and TrueTrue>>> (1 == 1) or FalseTrue>>>

>>> (1 == 1) and TrueTrue>>> (1 == 1) or FalseTrue>>> not (1 == 1)

Page 127: Python @NCKU CSIE

Logical Operators

and and

or or

not not

>>> >>> (1 == 1) and True>>> (1 == 1) and TrueTrue>>>

>>> (1 == 1) and TrueTrue>>> (1 == 1) or False

>>> (1 == 1) and TrueTrue>>> (1 == 1) or FalseTrue>>>

>>> (1 == 1) and TrueTrue>>> (1 == 1) or FalseTrue>>> not (1 == 1)

>>> (1 == 1) and TrueTrue>>> (1 == 1) or FalseTrue>>> not (1 == 1)False>>>

Page 128: Python @NCKU CSIE

Numbers

int(integer)

long(long integer)

float(real number)

complex(complex number)

10 10L 100.0 3 + 2j

-789 -789L -21.9 3 - 2j

-0x111 0xFFFFFFFFF 3.20E+10 45j

0x69 -0x12321L -2.00E-08 3e+26j

Page 129: Python @NCKU CSIE

Initialization / Conversiondata type initial

int int(x)

long long(x)

float float(x)

complex complex(x)complex(x, y)

>>>

Page 130: Python @NCKU CSIE

Initialization / Conversiondata type initial

int int(x)

long long(x)

float float(x)

complex complex(x)complex(x, y)

>>> >>> int(10)

Page 131: Python @NCKU CSIE

Initialization / Conversiondata type initial

int int(x)

long long(x)

float float(x)

complex complex(x)complex(x, y)

>>> >>> int(10)>>> int(10)10>>>

Page 132: Python @NCKU CSIE

Initialization / Conversiondata type initial

int int(x)

long long(x)

float float(x)

complex complex(x)complex(x, y)

>>> >>> int(10)>>> int(10)10>>>

>>> int(10)10>>> int(“100”)

Page 133: Python @NCKU CSIE

Initialization / Conversiondata type initial

int int(x)

long long(x)

float float(x)

complex complex(x)complex(x, y)

>>> >>> int(10)>>> int(10)10>>>

>>> int(10)10>>> int(“100”)

>>> int(10)10>>> int(“100”)100>>>

Page 134: Python @NCKU CSIE

Initialization / Conversiondata type initial

int int(x)

long long(x)

float float(x)

complex complex(x)complex(x, y)

>>> >>> int(10)>>> int(10)10>>>

>>> int(10)10>>> int(“100”)

>>> int(10)10>>> int(“100”)100>>>

>>> int(10)10>>> int(“100”)100>>> complex(10)

Page 135: Python @NCKU CSIE

Initialization / Conversiondata type initial

int int(x)

long long(x)

float float(x)

complex complex(x)complex(x, y)

>>> >>> int(10)>>> int(10)10>>>

>>> int(10)10>>> int(“100”)

>>> int(10)10>>> int(“100”)100>>>

>>> int(10)10>>> int(“100”)100>>> complex(10)

>>> int(10)10>>> int(“100”)100>>> complex(10)(10+0j)>>>

Page 136: Python @NCKU CSIE

Initialization / Conversiondata type initial

int int(x)

long long(x)

float float(x)

complex complex(x)complex(x, y)

>>> >>> int(10)>>> int(10)10>>>

>>> int(10)10>>> int(“100”)

>>> int(10)10>>> int(“100”)100>>>

>>> int(10)10>>> int(“100”)100>>> complex(10)

>>> int(10)10>>> int(“100”)100>>> complex(10)(10+0j)>>>

>>> int(10)10>>> int(“100”)100>>> complex(10)(10+0j)>>> complex(10, 3)

Page 137: Python @NCKU CSIE

Initialization / Conversiondata type initial

int int(x)

long long(x)

float float(x)

complex complex(x)complex(x, y)

>>> >>> int(10)>>> int(10)10>>>

>>> int(10)10>>> int(“100”)

>>> int(10)10>>> int(“100”)100>>>

>>> int(10)10>>> int(“100”)100>>> complex(10)

>>> int(10)10>>> int(“100”)100>>> complex(10)(10+0j)>>>

>>> int(10)10>>> int(“100”)100>>> complex(10)(10+0j)>>> complex(10, 3)

10>>> int(“100”)100>>> complex(10)(10+0j)>>> complex(10, 3)(10+3j)>>>

Page 138: Python @NCKU CSIE

Initialization / Conversiondata type initial

int int(x)

long long(x)

float float(x)

complex complex(x)complex(x, y)

>>> >>> int(10)>>> int(10)10>>>

>>> int(10)10>>> int(“100”)

>>> int(10)10>>> int(“100”)100>>>

>>> int(10)10>>> int(“100”)100>>> complex(10)

>>> int(10)10>>> int(“100”)100>>> complex(10)(10+0j)>>>

>>> int(10)10>>> int(“100”)100>>> complex(10)(10+0j)>>> complex(10, 3)

10>>> int(“100”)100>>> complex(10)(10+0j)>>> complex(10, 3)(10+3j)>>>

10>>> int(“100”)100>>> complex(10)(10+0j)>>> complex(10, 3)(10+3j)>>> complex(“20+5j”)

Page 139: Python @NCKU CSIE

Initialization / Conversiondata type initial

int int(x)

long long(x)

float float(x)

complex complex(x)complex(x, y)

>>> >>> int(10)>>> int(10)10>>>

>>> int(10)10>>> int(“100”)

>>> int(10)10>>> int(“100”)100>>>

>>> int(10)10>>> int(“100”)100>>> complex(10)

>>> int(10)10>>> int(“100”)100>>> complex(10)(10+0j)>>>

>>> int(10)10>>> int(“100”)100>>> complex(10)(10+0j)>>> complex(10, 3)

10>>> int(“100”)100>>> complex(10)(10+0j)>>> complex(10, 3)(10+3j)>>>

10>>> int(“100”)100>>> complex(10)(10+0j)>>> complex(10, 3)(10+3j)>>> complex(“20+5j”)

100>>> complex(10)(10+0j)>>> complex(10, 3)(10+3j)>>> complex(“20+5j”)(20+5j)>>>

Page 140: Python @NCKU CSIE

Arithmetic Operators+ addition

- subtraction

* multiplication/ division% modular

** exponential

// floor division

>>>

Page 141: Python @NCKU CSIE

Arithmetic Operators+ addition

- subtraction

* multiplication/ division% modular

** exponential

// floor division

>>> >>> 2**10

Page 142: Python @NCKU CSIE

Arithmetic Operators+ addition

- subtraction

* multiplication/ division% modular

** exponential

// floor division

>>> >>> 2**10>>> 2**101024>>>

Page 143: Python @NCKU CSIE

Arithmetic Operators+ addition

- subtraction

* multiplication/ division% modular

** exponential

// floor division

>>> >>> 2**10>>> 2**101024>>>

>>> 2**101024>>> 5.8 // 2

Page 144: Python @NCKU CSIE

Arithmetic Operators+ addition

- subtraction

* multiplication/ division% modular

** exponential

// floor division

>>> >>> 2**10>>> 2**101024>>>

>>> 2**101024>>> 5.8 // 2

>>> 2**101024>>> 5.8 // 22.0>>>

Page 145: Python @NCKU CSIE

Bitwise Operators& and

| or

^ exclusion or>> shift right<< shift left

~ not

>>>

Page 146: Python @NCKU CSIE

Bitwise Operators& and

| or

^ exclusion or>> shift right<< shift left

~ not

>>>>>> 3 & 1

Page 147: Python @NCKU CSIE

Bitwise Operators& and

| or

^ exclusion or>> shift right<< shift left

~ not

>>>>>> 3 & 1>>> 3 & 11>>>

Page 148: Python @NCKU CSIE

Bitwise Operators& and

| or

^ exclusion or>> shift right<< shift left

~ not

>>>>>> 3 & 1>>> 3 & 11>>>

>>> 3 & 11>>> 1 << 10

Page 149: Python @NCKU CSIE

Bitwise Operators& and

| or

^ exclusion or>> shift right<< shift left

~ not

>>>>>> 3 & 1>>> 3 & 11>>>

>>> 3 & 11>>> 1 << 10

>>> 3 & 11>>> 1 << 101024>>>

Page 150: Python @NCKU CSIE

Bitwise Operators& and

| or

^ exclusion or>> shift right<< shift left

~ not

>>>>>> 3 & 1>>> 3 & 11>>>

>>> 3 & 11>>> 1 << 10

>>> 3 & 11>>> 1 << 101024>>>

>>> 3 & 11>>> 1 << 101024>>> ~0

Page 151: Python @NCKU CSIE

Bitwise Operators& and

| or

^ exclusion or>> shift right<< shift left

~ not

>>>>>> 3 & 1>>> 3 & 11>>>

>>> 3 & 11>>> 1 << 10

>>> 3 & 11>>> 1 << 101024>>>

>>> 3 & 11>>> 1 << 101024>>> ~0

>>> 3 & 11>>> 1 << 101024>>> ~0-1>>>

Page 152: Python @NCKU CSIE

Comparison Operators> greater than

>= greater than or equal to

< less than<= less than or equal to == equal to

!= not equal to

Page 153: Python @NCKU CSIE

String

Contents are surrounded by single quote or double quote.

>>>

Page 154: Python @NCKU CSIE

String

Contents are surrounded by single quote or double quote.

>>>>>> “Hello World”

Page 155: Python @NCKU CSIE

String

Contents are surrounded by single quote or double quote.

>>>>>> “Hello World”>>> “Hello World”‘Hello World’>>>

Page 156: Python @NCKU CSIE

String

Contents are surrounded by single quote or double quote.

>>>>>> “Hello World”>>> “Hello World”‘Hello World’>>>

>>> “Hello World!”‘Hello World’>>> ‘Hello World!’

Page 157: Python @NCKU CSIE

String

Contents are surrounded by single quote or double quote.

>>>>>> “Hello World”>>> “Hello World”‘Hello World’>>>

>>> “Hello World!”‘Hello World’>>> ‘Hello World!’

>>> “Hello World!”‘Hello World’>>> ‘Hello World!’‘Hello World’>>>

Page 158: Python @NCKU CSIE

Cross-line String

Contents are surrounded by three single quotes or three double quotes.

>>>

Page 159: Python @NCKU CSIE

Cross-line String

Contents are surrounded by three single quotes or three double quotes.

>>> >>> “““Hello

Page 160: Python @NCKU CSIE

Cross-line String

Contents are surrounded by three single quotes or three double quotes.

>>> >>> “““Hello>>> “““Hello...

Page 161: Python @NCKU CSIE

Cross-line String

Contents are surrounded by three single quotes or three double quotes.

>>> >>> “““Hello>>> “““Hello... >>> “““Hello... World!”””

Page 162: Python @NCKU CSIE

Cross-line String

Contents are surrounded by three single quotes or three double quotes.

>>> >>> “““Hello>>> “““Hello... >>> “““Hello... World!”””>>> “““Hello... World!”””‘Hello\nWorld!’>>>

Page 163: Python @NCKU CSIE

Cross-line String

Contents are surrounded by three single quotes or three double quotes.

>>> >>> “““Hello>>> “““Hello... >>> “““Hello... World!”””>>> “““Hello... World!”””‘Hello\nWorld!’>>>

>>> “““Hello... World!”””‘Hello\nWorld!’>>> x = “““Hello

Page 164: Python @NCKU CSIE

Cross-line String

Contents are surrounded by three single quotes or three double quotes.

>>> >>> “““Hello>>> “““Hello... >>> “““Hello... World!”””>>> “““Hello... World!”””‘Hello\nWorld!’>>>

>>> “““Hello... World!”””‘Hello\nWorld!’>>> x = “““Hello

>>> “““Hello... World!”””‘Hello\nWorld!’>>> x = “““Hello...

Page 165: Python @NCKU CSIE

Cross-line String

Contents are surrounded by three single quotes or three double quotes.

>>> >>> “““Hello>>> “““Hello... >>> “““Hello... World!”””>>> “““Hello... World!”””‘Hello\nWorld!’>>>

>>> “““Hello... World!”””‘Hello\nWorld!’>>> x = “““Hello

>>> “““Hello... World!”””‘Hello\nWorld!’>>> x = “““Hello...

>>> “““Hello... World!”””‘Hello\nWorld!’>>> x = “““Hello... World!”””

Page 166: Python @NCKU CSIE

Cross-line String

Contents are surrounded by three single quotes or three double quotes.

>>> >>> “““Hello>>> “““Hello... >>> “““Hello... World!”””>>> “““Hello... World!”””‘Hello\nWorld!’>>>

>>> “““Hello... World!”””‘Hello\nWorld!’>>> x = “““Hello

>>> “““Hello... World!”””‘Hello\nWorld!’>>> x = “““Hello...

>>> “““Hello... World!”””‘Hello\nWorld!’>>> x = “““Hello... World!”””

>>> “““Hello... World!”””‘Hello\nWorld!’>>> x = “““Hello... World!”””>>>

Page 167: Python @NCKU CSIE

Cross-line String

Contents are surrounded by three single quotes or three double quotes.

>>> >>> “““Hello>>> “““Hello... >>> “““Hello... World!”””>>> “““Hello... World!”””‘Hello\nWorld!’>>>

>>> “““Hello... World!”””‘Hello\nWorld!’>>> x = “““Hello

>>> “““Hello... World!”””‘Hello\nWorld!’>>> x = “““Hello...

>>> “““Hello... World!”””‘Hello\nWorld!’>>> x = “““Hello... World!”””

>>> “““Hello... World!”””‘Hello\nWorld!’>>> x = “““Hello... World!”””>>>

>>> “““Hello... World!”””‘Hello\nWorld!’>>> x = “““Hello... World!”””>>> print x

Page 168: Python @NCKU CSIE

Cross-line String

Contents are surrounded by three single quotes or three double quotes.

>>> >>> “““Hello>>> “““Hello... >>> “““Hello... World!”””>>> “““Hello... World!”””‘Hello\nWorld!’>>>

>>> “““Hello... World!”””‘Hello\nWorld!’>>> x = “““Hello

>>> “““Hello... World!”””‘Hello\nWorld!’>>> x = “““Hello...

>>> “““Hello... World!”””‘Hello\nWorld!’>>> x = “““Hello... World!”””

>>> “““Hello... World!”””‘Hello\nWorld!’>>> x = “““Hello... World!”””>>>

>>> “““Hello... World!”””‘Hello\nWorld!’>>> x = “““Hello... World!”””>>> print x

... World!”””‘Hello\nWorld!’>>> x = “““Hello... World!”””>>> print xHelloWorld!>>>

Page 169: Python @NCKU CSIE

Initialization / Conversion

>>>

Page 170: Python @NCKU CSIE

Initialization / Conversion

>>> >>> str(“I’m string”)

Page 171: Python @NCKU CSIE

Initialization / Conversion

>>> >>> str(“I’m string”)>>> str(“I’m string”)“I’m string”>>>

Page 172: Python @NCKU CSIE

Initialization / Conversion

>>> >>> str(“I’m string”)>>> str(“I’m string”)“I’m string”>>>

>>> str(“I’m string”)“I’m string”>>> str(100)

Page 173: Python @NCKU CSIE

Initialization / Conversion

>>> >>> str(“I’m string”)>>> str(“I’m string”)“I’m string”>>>

>>> str(“I’m string”)“I’m string”>>> str(100)

>>> str(“I’m string”)“I’m string”>>> str(100)‘100’>>>

Page 174: Python @NCKU CSIE

Initialization / Conversion

>>> >>> str(“I’m string”)>>> str(“I’m string”)“I’m string”>>>

>>> str(“I’m string”)“I’m string”>>> str(100)

>>> str(“I’m string”)“I’m string”>>> str(100)‘100’>>>

>>> str(“I’m string”)“I’m string”>>> str(100)‘100’>>> str(complex(10, 3))

Page 175: Python @NCKU CSIE

Initialization / Conversion

>>> >>> str(“I’m string”)>>> str(“I’m string”)“I’m string”>>>

>>> str(“I’m string”)“I’m string”>>> str(100)

>>> str(“I’m string”)“I’m string”>>> str(100)‘100’>>>

>>> str(“I’m string”)“I’m string”>>> str(100)‘100’>>> str(complex(10, 3))

>>> str(“I’m string”)“I’m string”>>> str(100)‘100’>>> str(complex(10, 3))‘(10+3j)’>>>

Page 176: Python @NCKU CSIE

>>>

Operators

+ concatenate

* repeat

Page 177: Python @NCKU CSIE

>>>>>> x = “abc”

Operators

+ concatenate

* repeat

Page 178: Python @NCKU CSIE

>>>>>> x = “abc”>>> x = “abc”>>>

Operators

+ concatenate

* repeat

Page 179: Python @NCKU CSIE

>>>>>> x = “abc”>>> x = “abc”>>> >>> x = “abc”>>> ‘(’ + x + ‘)’

Operators

+ concatenate

* repeat

Page 180: Python @NCKU CSIE

>>>>>> x = “abc”>>> x = “abc”>>> >>> x = “abc”>>> ‘(’ + x + ‘)’>>> x = “abc”>>> ‘(’ + x + ‘)’‘(abc)’>>>

Operators

+ concatenate

* repeat

Page 181: Python @NCKU CSIE

>>>>>> x = “abc”>>> x = “abc”>>> >>> x = “abc”>>> ‘(’ + x + ‘)’>>> x = “abc”>>> ‘(’ + x + ‘)’‘(abc)’>>>

>>> x = “abc”>>> ‘(’ + x + ‘)’‘(abc)’>>> x * 3

Operators

+ concatenate

* repeat

Page 182: Python @NCKU CSIE

>>>>>> x = “abc”>>> x = “abc”>>> >>> x = “abc”>>> ‘(’ + x + ‘)’>>> x = “abc”>>> ‘(’ + x + ‘)’‘(abc)’>>>

>>> x = “abc”>>> ‘(’ + x + ‘)’‘(abc)’>>> x * 3

>>> x = “abc”>>> ‘(’ + x + ‘)’‘(abc)’>>> x * 3‘abcabcabc’>>>

Operators

+ concatenate

* repeat

Page 183: Python @NCKU CSIE

>>>>>> x = “abc”>>> x = “abc”>>> >>> x = “abc”>>> ‘(’ + x + ‘)’>>> x = “abc”>>> ‘(’ + x + ‘)’‘(abc)’>>>

>>> x = “abc”>>> ‘(’ + x + ‘)’‘(abc)’>>> x * 3

>>> x = “abc”>>> ‘(’ + x + ‘)’‘(abc)’>>> x * 3‘abcabcabc’>>>

>>> x = “abc”>>> ‘(’ + x + ‘)’‘(abc)’>>> x * 3‘abcabcabc’>>> ‘(’ + x * 3 + ‘)’

Operators

+ concatenate

* repeat

Page 184: Python @NCKU CSIE

>>>>>> x = “abc”>>> x = “abc”>>> >>> x = “abc”>>> ‘(’ + x + ‘)’>>> x = “abc”>>> ‘(’ + x + ‘)’‘(abc)’>>>

>>> x = “abc”>>> ‘(’ + x + ‘)’‘(abc)’>>> x * 3

>>> x = “abc”>>> ‘(’ + x + ‘)’‘(abc)’>>> x * 3‘abcabcabc’>>>

>>> x = “abc”>>> ‘(’ + x + ‘)’‘(abc)’>>> x * 3‘abcabcabc’>>> ‘(’ + x * 3 + ‘)’

>>> x = ‘abc’>>> ‘(’ + x + ‘)’‘(abc)’>>> x * 3‘abcabcabc’>>> ‘(’ + x * 3 + ‘)’‘(abcabcabc)’>>>

Operators

+ concatenate

* repeat

Page 185: Python @NCKU CSIE

>>>>>> x = “abc”>>> x = “abc”>>> >>> x = “abc”>>> ‘(’ + x + ‘)’>>> x = “abc”>>> ‘(’ + x + ‘)’‘(abc)’>>>

>>> x = “abc”>>> ‘(’ + x + ‘)’‘(abc)’>>> x * 3

>>> x = “abc”>>> ‘(’ + x + ‘)’‘(abc)’>>> x * 3‘abcabcabc’>>>

>>> x = “abc”>>> ‘(’ + x + ‘)’‘(abc)’>>> x * 3‘abcabcabc’>>> ‘(’ + x * 3 + ‘)’

>>> x = ‘abc’>>> ‘(’ + x + ‘)’‘(abc)’>>> x * 3‘abcabcabc’>>> ‘(’ + x * 3 + ‘)’‘(abcabcabc)’>>>

>>> x = ‘abc’>>> ‘(’ + x + ‘)’‘(abc)’>>> x * 3‘abcabcabc’>>> ‘(’ + x * 3 + ‘)’‘(abcabcabc)’>>> (x + ‘d’) * 3

Operators

+ concatenate

* repeat

Page 186: Python @NCKU CSIE

>>>>>> x = “abc”>>> x = “abc”>>> >>> x = “abc”>>> ‘(’ + x + ‘)’>>> x = “abc”>>> ‘(’ + x + ‘)’‘(abc)’>>>

>>> x = “abc”>>> ‘(’ + x + ‘)’‘(abc)’>>> x * 3

>>> x = “abc”>>> ‘(’ + x + ‘)’‘(abc)’>>> x * 3‘abcabcabc’>>>

>>> x = “abc”>>> ‘(’ + x + ‘)’‘(abc)’>>> x * 3‘abcabcabc’>>> ‘(’ + x * 3 + ‘)’

>>> x = ‘abc’>>> ‘(’ + x + ‘)’‘(abc)’>>> x * 3‘abcabcabc’>>> ‘(’ + x * 3 + ‘)’‘(abcabcabc)’>>>

>>> x = ‘abc’>>> ‘(’ + x + ‘)’‘(abc)’>>> x * 3‘abcabcabc’>>> ‘(’ + x * 3 + ‘)’‘(abcabcabc)’>>> (x + ‘d’) * 3

‘(abc)’>>> x * 3‘abcabcabc’>>> ‘(’ + x * 3 + ‘)’‘(abcabcabc)’>>> (x + ‘d’) * 3‘abcdabcdabcd’>>>

Operators

+ concatenate

* repeat

Page 187: Python @NCKU CSIE

>>>

Access Character

Page 188: Python @NCKU CSIE

>>>>>> x = ‘0123456789’

Access Character

Page 189: Python @NCKU CSIE

>>>>>> x = ‘0123456789’>>> x = ‘0123456789’>>>

Access Character

Page 190: Python @NCKU CSIE

>>>>>> x = ‘0123456789’>>> x = ‘0123456789’>>> >>> x = ‘0123456789’>>> x[1]

Access Character

Page 191: Python @NCKU CSIE

>>>>>> x = ‘0123456789’>>> x = ‘0123456789’>>> >>> x = ‘0123456789’>>> x[1]>>> x = ‘0123456789’>>> x[1]‘1’>>>

Access Character

Page 192: Python @NCKU CSIE

>>>>>> x = ‘0123456789’>>> x = ‘0123456789’>>> >>> x = ‘0123456789’>>> x[1]>>> x = ‘0123456789’>>> x[1]‘1’>>>

>>> x = ‘0123456789’>>> x[1]‘1’>>> x[1] = ‘0’

Access Character

Page 193: Python @NCKU CSIE

>>>>>> x = ‘0123456789’>>> x = ‘0123456789’>>> >>> x = ‘0123456789’>>> x[1]>>> x = ‘0123456789’>>> x[1]‘1’>>>

>>> x = ‘0123456789’>>> x[1]‘1’>>> x[1] = ‘0’

>>> x = ‘0123456789’>>> x[1]‘1’>>> x[1] = ‘0’>>>

Access Character

Page 194: Python @NCKU CSIE

>>>>>> x = ‘0123456789’>>> x = ‘0123456789’>>> >>> x = ‘0123456789’>>> x[1]>>> x = ‘0123456789’>>> x[1]‘1’>>>

>>> x = ‘0123456789’>>> x[1]‘1’>>> x[1] = ‘0’

>>> x = ‘0123456789’>>> x[1]‘1’>>> x[1] = ‘0’>>>

>>> x = ‘0123456789’>>> x[1]‘1’>>> x[1] = ‘0’>>> x

Access Character

Page 195: Python @NCKU CSIE

>>>>>> x = ‘0123456789’>>> x = ‘0123456789’>>> >>> x = ‘0123456789’>>> x[1]>>> x = ‘0123456789’>>> x[1]‘1’>>>

>>> x = ‘0123456789’>>> x[1]‘1’>>> x[1] = ‘0’

>>> x = ‘0123456789’>>> x[1]‘1’>>> x[1] = ‘0’>>>

>>> x = ‘0123456789’>>> x[1]‘1’>>> x[1] = ‘0’>>> x

>>> x = ‘0123456789’>>> x[1]‘1’>>> x[1] = ‘0’>>> x‘0023456789’>>>

Access Character

Page 196: Python @NCKU CSIE

>>>

substring

[start:end(:step)]

Page 197: Python @NCKU CSIE

>>>

substring

[start:end(:step)]

[0:length(:1)]

default value

Page 198: Python @NCKU CSIE

>>>>>> x = “0123456789”

substring

[start:end(:step)]

[0:length(:1)]

default value

Page 199: Python @NCKU CSIE

>>>>>> x = “0123456789”>>> x = “0123456789”>>>

substring

[start:end(:step)]

[0:length(:1)]

default value

Page 200: Python @NCKU CSIE

>>>>>> x = “0123456789”>>> x = “0123456789”>>>>>> x = “0123456789”>>> x[::]

substring

[start:end(:step)]

[0:length(:1)]

default value

Page 201: Python @NCKU CSIE

>>>>>> x = “0123456789”>>> x = “0123456789”>>>>>> x = “0123456789”>>> x[::]>>> x = “0123456789”>>> x[::]‘0123456789’>>>

substring

[start:end(:step)]

[0:length(:1)]

default value

Page 202: Python @NCKU CSIE

>>>>>> x = “0123456789”>>> x = “0123456789”>>>>>> x = “0123456789”>>> x[::]>>> x = “0123456789”>>> x[::]‘0123456789’>>>

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]

substring

[start:end(:step)]

[0:length(:1)]

default value

Page 203: Python @NCKU CSIE

>>>>>> x = “0123456789”>>> x = “0123456789”>>>>>> x = “0123456789”>>> x[::]>>> x = “0123456789”>>> x[::]‘0123456789’>>>

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]‘0123456789’>>>

substring

[start:end(:step)]

[0:length(:1)]

default value

Page 204: Python @NCKU CSIE

>>>>>> x = “0123456789”>>> x = “0123456789”>>>>>> x = “0123456789”>>> x[::]>>> x = “0123456789”>>> x[::]‘0123456789’>>>

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]‘0123456789’>>>

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]‘0123456789’>>> x[1:4]

substring

[start:end(:step)]

[0:length(:1)]

default value

Page 205: Python @NCKU CSIE

>>>>>> x = “0123456789”>>> x = “0123456789”>>>>>> x = “0123456789”>>> x[::]>>> x = “0123456789”>>> x[::]‘0123456789’>>>

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]‘0123456789’>>>

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]‘0123456789’>>> x[1:4]

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]‘0123456789’>>> x[1:4]‘123’>>>

substring

[start:end(:step)]

[0:length(:1)]

default value

Page 206: Python @NCKU CSIE

>>>>>> x = “0123456789”>>> x = “0123456789”>>>>>> x = “0123456789”>>> x[::]>>> x = “0123456789”>>> x[::]‘0123456789’>>>

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]‘0123456789’>>>

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]‘0123456789’>>> x[1:4]

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]‘0123456789’>>> x[1:4]‘123’>>>

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]‘0123456789’>>> x[1:4]‘123’>>> x[1:-1]

substring

[start:end(:step)]

[0:length(:1)]

default value

Page 207: Python @NCKU CSIE

>>>>>> x = “0123456789”>>> x = “0123456789”>>>>>> x = “0123456789”>>> x[::]>>> x = “0123456789”>>> x[::]‘0123456789’>>>

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]‘0123456789’>>>

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]‘0123456789’>>> x[1:4]

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]‘0123456789’>>> x[1:4]‘123’>>>

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]‘0123456789’>>> x[1:4]‘123’>>> x[1:-1]

‘0123456789’>>> x[:]‘0123456789’>>> x[1:4]‘123’>>> x[1:-1]‘12345678’>>>

substring

[start:end(:step)]

[0:length(:1)]

default value

Page 208: Python @NCKU CSIE

>>>>>> x = “0123456789”>>> x = “0123456789”>>>>>> x = “0123456789”>>> x[::]>>> x = “0123456789”>>> x[::]‘0123456789’>>>

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]‘0123456789’>>>

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]‘0123456789’>>> x[1:4]

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]‘0123456789’>>> x[1:4]‘123’>>>

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]‘0123456789’>>> x[1:4]‘123’>>> x[1:-1]

‘0123456789’>>> x[:]‘0123456789’>>> x[1:4]‘123’>>> x[1:-1]‘12345678’>>>

‘0123456789’>>> x[:]‘0123456789’>>> x[1:4]‘123’>>> x[1:-1]‘12345678’>>> x[::2]

substring

[start:end(:step)]

[0:length(:1)]

default value

Page 209: Python @NCKU CSIE

>>>>>> x = “0123456789”>>> x = “0123456789”>>>>>> x = “0123456789”>>> x[::]>>> x = “0123456789”>>> x[::]‘0123456789’>>>

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]‘0123456789’>>>

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]‘0123456789’>>> x[1:4]

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]‘0123456789’>>> x[1:4]‘123’>>>

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]‘0123456789’>>> x[1:4]‘123’>>> x[1:-1]

‘0123456789’>>> x[:]‘0123456789’>>> x[1:4]‘123’>>> x[1:-1]‘12345678’>>>

‘0123456789’>>> x[:]‘0123456789’>>> x[1:4]‘123’>>> x[1:-1]‘12345678’>>> x[::2]

‘0123456789’>>> x[1:4]‘123’>>> x[1:-1]‘12345678’>>> x[::2]‘02468’>>>

substring

[start:end(:step)]

[0:length(:1)]

default value

Page 210: Python @NCKU CSIE

>>>>>> x = “0123456789”>>> x = “0123456789”>>>>>> x = “0123456789”>>> x[::]>>> x = “0123456789”>>> x[::]‘0123456789’>>>

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]‘0123456789’>>>

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]‘0123456789’>>> x[1:4]

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]‘0123456789’>>> x[1:4]‘123’>>>

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]‘0123456789’>>> x[1:4]‘123’>>> x[1:-1]

‘0123456789’>>> x[:]‘0123456789’>>> x[1:4]‘123’>>> x[1:-1]‘12345678’>>>

‘0123456789’>>> x[:]‘0123456789’>>> x[1:4]‘123’>>> x[1:-1]‘12345678’>>> x[::2]

‘0123456789’>>> x[1:4]‘123’>>> x[1:-1]‘12345678’>>> x[::2]‘02468’>>>

‘0123456789’>>> x[1:4]‘123’>>> x[1:-1]‘12345678’>>> x[::2]‘02468’>>> x[::-1]

substring

[start:end(:step)]

[0:length(:1)]

default value

Page 211: Python @NCKU CSIE

>>>>>> x = “0123456789”>>> x = “0123456789”>>>>>> x = “0123456789”>>> x[::]>>> x = “0123456789”>>> x[::]‘0123456789’>>>

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]‘0123456789’>>>

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]‘0123456789’>>> x[1:4]

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]‘0123456789’>>> x[1:4]‘123’>>>

>>> x = “0123456789”>>> x[::]‘0123456789’>>> x[:]‘0123456789’>>> x[1:4]‘123’>>> x[1:-1]

‘0123456789’>>> x[:]‘0123456789’>>> x[1:4]‘123’>>> x[1:-1]‘12345678’>>>

‘0123456789’>>> x[:]‘0123456789’>>> x[1:4]‘123’>>> x[1:-1]‘12345678’>>> x[::2]

‘0123456789’>>> x[1:4]‘123’>>> x[1:-1]‘12345678’>>> x[::2]‘02468’>>>

‘0123456789’>>> x[1:4]‘123’>>> x[1:-1]‘12345678’>>> x[::2]‘02468’>>> x[::-1]

‘123’>>> x[1:-1]‘12345678’>>> x[::2]‘02468’>>> x[::-1]‘9876543210’>>>

substring

[start:end(:step)]

[0:length(:1)]

default value

Page 212: Python @NCKU CSIE

length of string

len(string)>>>

Page 213: Python @NCKU CSIE

length of string

len(string)>>>>>> x = ‘0123456789’

Page 214: Python @NCKU CSIE

length of string

len(string)>>>>>> x = ‘0123456789’>>> x = ‘0123456789’>>>

Page 215: Python @NCKU CSIE

length of string

len(string)>>>>>> x = ‘0123456789’>>> x = ‘0123456789’>>> >>> x = ‘0123456789’>>> len(x)

Page 216: Python @NCKU CSIE

length of string

len(string)>>>>>> x = ‘0123456789’>>> x = ‘0123456789’>>> >>> x = ‘0123456789’>>> len(x)>>> x = ‘0123456789’>>> len(x)10>>>

Page 217: Python @NCKU CSIE

length of string

len(string)>>>>>> x = ‘0123456789’>>> x = ‘0123456789’>>> >>> x = ‘0123456789’>>> len(x)>>> x = ‘0123456789’>>> len(x)10>>>

>>> x = ‘0123456789’>>> len(x)10>>> len(x[::2])

Page 218: Python @NCKU CSIE

length of string

len(string)>>>>>> x = ‘0123456789’>>> x = ‘0123456789’>>> >>> x = ‘0123456789’>>> len(x)>>> x = ‘0123456789’>>> len(x)10>>>

>>> x = ‘0123456789’>>> len(x)10>>> len(x[::2])

>>> x = ‘0123456789’>>> len(x)10>>> len(x[::2])5>>>

Page 219: Python @NCKU CSIE

List

Contents are surrounded by square brackets and separate by comma.

>>>

Page 220: Python @NCKU CSIE

List

Contents are surrounded by square brackets and separate by comma.

>>> >>> [“aaa”, “bbb”, 1, 2]

Page 221: Python @NCKU CSIE

List

Contents are surrounded by square brackets and separate by comma.

>>> >>> [“aaa”, “bbb”, 1, 2]>>> [“aaa”, “bbb”, 1, 2][‘aaa’, ‘bbb’, 1, 2]>>>

Page 222: Python @NCKU CSIE

Initialization / Conversion

>>>

Page 223: Python @NCKU CSIE

Initialization / Conversion

>>> >>> list([1, 2, 3])

Page 224: Python @NCKU CSIE

Initialization / Conversion

>>> >>> list([1, 2, 3])>>> list([1, 2, 3])[1, 2, 3]>>>

Page 225: Python @NCKU CSIE

Initialization / Conversion

>>> >>> list([1, 2, 3])>>> list([1, 2, 3])[1, 2, 3]>>>

>>> list([1, 2, 3])[1, 2, 3]>>> list(“abc”)

Page 226: Python @NCKU CSIE

Initialization / Conversion

>>> >>> list([1, 2, 3])>>> list([1, 2, 3])[1, 2, 3]>>>

>>> list([1, 2, 3])[1, 2, 3]>>> list(“abc”)

>>> list([1, 2, 3])[1, 2, 3]>>> list(“abc”)[‘a’, ‘b’, ‘c’]>>>

Page 227: Python @NCKU CSIE

Operators

+ append

* repeat

>>>

Page 228: Python @NCKU CSIE

Operators

+ append

* repeat

>>>>>> x = [1, 2, 3]

Page 229: Python @NCKU CSIE

Operators

+ append

* repeat

>>>>>> x = [1, 2, 3]>>> x = [1, 2, 3]>>>

Page 230: Python @NCKU CSIE

Operators

+ append

* repeat

>>>>>> x = [1, 2, 3]>>> x = [1, 2, 3]>>>>>> x = [1, 2, 3]>>> y = [‘a’, ‘b’]

Page 231: Python @NCKU CSIE

Operators

+ append

* repeat

>>>>>> x = [1, 2, 3]>>> x = [1, 2, 3]>>>>>> x = [1, 2, 3]>>> y = [‘a’, ‘b’]>>> x = [1, 2, 3]>>> y = [‘a’, ‘b’]>>>

Page 232: Python @NCKU CSIE

Operators

+ append

* repeat

>>>>>> x = [1, 2, 3]>>> x = [1, 2, 3]>>>>>> x = [1, 2, 3]>>> y = [‘a’, ‘b’]>>> x = [1, 2, 3]>>> y = [‘a’, ‘b’]>>>

>>> x = [1, 2, 3]>>> y = [‘a’, ‘b’]>>> x * 2

Page 233: Python @NCKU CSIE

Operators

+ append

* repeat

>>>>>> x = [1, 2, 3]>>> x = [1, 2, 3]>>>>>> x = [1, 2, 3]>>> y = [‘a’, ‘b’]>>> x = [1, 2, 3]>>> y = [‘a’, ‘b’]>>>

>>> x = [1, 2, 3]>>> y = [‘a’, ‘b’]>>> x * 2

>>> x = [1, 2, 3]>>> y = [‘a’, ‘b’]>>> x * 2[1, 2, 3, 1, 2, 3]>>>

Page 234: Python @NCKU CSIE

Operators

+ append

* repeat

>>>>>> x = [1, 2, 3]>>> x = [1, 2, 3]>>>>>> x = [1, 2, 3]>>> y = [‘a’, ‘b’]>>> x = [1, 2, 3]>>> y = [‘a’, ‘b’]>>>

>>> x = [1, 2, 3]>>> y = [‘a’, ‘b’]>>> x * 2

>>> x = [1, 2, 3]>>> y = [‘a’, ‘b’]>>> x * 2[1, 2, 3, 1, 2, 3]>>>

>>> x = [1, 2, 3]>>> y = [‘a’, ‘b’]>>> x * 2[1, 2, 3, 1, 2, 3]>>> x + y

Page 235: Python @NCKU CSIE

Operators

+ append

* repeat

>>>>>> x = [1, 2, 3]>>> x = [1, 2, 3]>>>>>> x = [1, 2, 3]>>> y = [‘a’, ‘b’]>>> x = [1, 2, 3]>>> y = [‘a’, ‘b’]>>>

>>> x = [1, 2, 3]>>> y = [‘a’, ‘b’]>>> x * 2

>>> x = [1, 2, 3]>>> y = [‘a’, ‘b’]>>> x * 2[1, 2, 3, 1, 2, 3]>>>

>>> x = [1, 2, 3]>>> y = [‘a’, ‘b’]>>> x * 2[1, 2, 3, 1, 2, 3]>>> x + y

>>> x = [1, 2, 3]>>> y = [‘a’, ‘b’]>>> x * 2[1, 2, 3, 1, 2, 3]>>> x + y[1, 2, 3, ‘a’, ‘b’]>>>

Page 236: Python @NCKU CSIE

>>>

Access Element

Page 237: Python @NCKU CSIE

>>>>>> x = [1, 2, 3, 4, 5]

Access Element

Page 238: Python @NCKU CSIE

>>>>>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>>

Access Element

Page 239: Python @NCKU CSIE

>>>>>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>> >>> x = [1, 2, 3, 4, 5]>>> x[1]

Access Element

Page 240: Python @NCKU CSIE

>>>>>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>> >>> x = [1, 2, 3, 4, 5]>>> x[1]>>> x = [1, 2, 3, 4, 5]>>> x[1]2>>>

Access Element

Page 241: Python @NCKU CSIE

>>>>>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>> >>> x = [1, 2, 3, 4, 5]>>> x[1]>>> x = [1, 2, 3, 4, 5]>>> x[1]2>>>

>>> x = [1, 2, 3, 4, 5]>>> x[1]2>>> x[1] = ‘0’

Access Element

Page 242: Python @NCKU CSIE

>>>>>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>> >>> x = [1, 2, 3, 4, 5]>>> x[1]>>> x = [1, 2, 3, 4, 5]>>> x[1]2>>>

>>> x = [1, 2, 3, 4, 5]>>> x[1]2>>> x[1] = ‘0’

>>> x = [1, 2, 3, 4, 5]>>> x[1]2>>> x[1] = ‘0’>>>

Access Element

Page 243: Python @NCKU CSIE

>>>>>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>> >>> x = [1, 2, 3, 4, 5]>>> x[1]>>> x = [1, 2, 3, 4, 5]>>> x[1]2>>>

>>> x = [1, 2, 3, 4, 5]>>> x[1]2>>> x[1] = ‘0’

>>> x = [1, 2, 3, 4, 5]>>> x[1]2>>> x[1] = ‘0’>>>

>>> x = [1, 2, 3, 4, 5]>>> x[1]2>>> x[1] = ‘0’>>> x

Access Element

Page 244: Python @NCKU CSIE

>>>>>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>> >>> x = [1, 2, 3, 4, 5]>>> x[1]>>> x = [1, 2, 3, 4, 5]>>> x[1]2>>>

>>> x = [1, 2, 3, 4, 5]>>> x[1]2>>> x[1] = ‘0’

>>> x = [1, 2, 3, 4, 5]>>> x[1]2>>> x[1] = ‘0’>>>

>>> x = [1, 2, 3, 4, 5]>>> x[1]2>>> x[1] = ‘0’>>> x

>>> x = [1, 2, 3, 4, 5]>>> x[1]2>>> x[1] = ‘0’>>> x[1, ‘0’, 3, 4, 5]>>>

Access Element

Page 245: Python @NCKU CSIE

>>>

Slice

[start:end(:step)]

Page 246: Python @NCKU CSIE

>>>

Slice

[start:end(:step)]

[0:length(:1)]

default value

Page 247: Python @NCKU CSIE

>>>>>> x = [1, 2, 3, 4, 5]

Slice

[start:end(:step)]

[0:length(:1)]

default value

Page 248: Python @NCKU CSIE

>>>>>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>>

Slice

[start:end(:step)]

[0:length(:1)]

default value

Page 249: Python @NCKU CSIE

>>>>>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>>>>> x = [1, 2, 3, 4, 5]>>> x[::]

Slice

[start:end(:step)]

[0:length(:1)]

default value

Page 250: Python @NCKU CSIE

>>>>>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>>>>> x = [1, 2, 3, 4, 5]>>> x[::]>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>>

Slice

[start:end(:step)]

[0:length(:1)]

default value

Page 251: Python @NCKU CSIE

>>>>>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>>>>> x = [1, 2, 3, 4, 5]>>> x[::]>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>>

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:]

Slice

[start:end(:step)]

[0:length(:1)]

default value

Page 252: Python @NCKU CSIE

>>>>>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>>>>> x = [1, 2, 3, 4, 5]>>> x[::]>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>>

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:]

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>>

Slice

[start:end(:step)]

[0:length(:1)]

default value

Page 253: Python @NCKU CSIE

>>>>>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>>>>> x = [1, 2, 3, 4, 5]>>> x[::]>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>>

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:]

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>>

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>> x[1:3]

Slice

[start:end(:step)]

[0:length(:1)]

default value

Page 254: Python @NCKU CSIE

>>>>>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>>>>> x = [1, 2, 3, 4, 5]>>> x[::]>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>>

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:]

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>>

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>> x[1:3]

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>> x[1:3][2, 3]>>>

Slice

[start:end(:step)]

[0:length(:1)]

default value

Page 255: Python @NCKU CSIE

>>>>>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>>>>> x = [1, 2, 3, 4, 5]>>> x[::]>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>>

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:]

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>>

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>> x[1:3]

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>> x[1:3][2, 3]>>>

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>> x[1:3][2, 3]>>> x[1:-1]

Slice

[start:end(:step)]

[0:length(:1)]

default value

Page 256: Python @NCKU CSIE

>>>>>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>>>>> x = [1, 2, 3, 4, 5]>>> x[::]>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>>

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:]

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>>

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>> x[1:3]

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>> x[1:3][2, 3]>>>

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>> x[1:3][2, 3]>>> x[1:-1]

[1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>> x[1:3][2, 3]>>> x[1:-1][2, 3, 4]>>>

Slice

[start:end(:step)]

[0:length(:1)]

default value

Page 257: Python @NCKU CSIE

>>>>>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>>>>> x = [1, 2, 3, 4, 5]>>> x[::]>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>>

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:]

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>>

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>> x[1:3]

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>> x[1:3][2, 3]>>>

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>> x[1:3][2, 3]>>> x[1:-1]

[1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>> x[1:3][2, 3]>>> x[1:-1][2, 3, 4]>>>

[1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>> x[1:3][2, 3]>>> x[1:-1][2, 3, 4]>>> x[::2]

Slice

[start:end(:step)]

[0:length(:1)]

default value

Page 258: Python @NCKU CSIE

>>>>>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>>>>> x = [1, 2, 3, 4, 5]>>> x[::]>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>>

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:]

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>>

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>> x[1:3]

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>> x[1:3][2, 3]>>>

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>> x[1:3][2, 3]>>> x[1:-1]

[1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>> x[1:3][2, 3]>>> x[1:-1][2, 3, 4]>>>

[1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>> x[1:3][2, 3]>>> x[1:-1][2, 3, 4]>>> x[::2]

[1, 2, 3, 4, 5]>>> x[1:3][2, 3]>>> x[1:-1][2, 3, 4]>>> x[::2][1, 3, 5]>>>

Slice

[start:end(:step)]

[0:length(:1)]

default value

Page 259: Python @NCKU CSIE

>>>>>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>>>>> x = [1, 2, 3, 4, 5]>>> x[::]>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>>

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:]

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>>

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>> x[1:3]

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>> x[1:3][2, 3]>>>

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>> x[1:3][2, 3]>>> x[1:-1]

[1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>> x[1:3][2, 3]>>> x[1:-1][2, 3, 4]>>>

[1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>> x[1:3][2, 3]>>> x[1:-1][2, 3, 4]>>> x[::2]

[1, 2, 3, 4, 5]>>> x[1:3][2, 3]>>> x[1:-1][2, 3, 4]>>> x[::2][1, 3, 5]>>>

[1, 2, 3, 4, 5]>>> x[1:3][2, 3]>>> x[1:-1][2, 3, 4]>>> x[::2][1, 3, 5]>>> x[::-1]

Slice

[start:end(:step)]

[0:length(:1)]

default value

Page 260: Python @NCKU CSIE

>>>>>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>>>>> x = [1, 2, 3, 4, 5]>>> x[::]>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>>

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:]

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>>

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>> x[1:3]

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>> x[1:3][2, 3]>>>

>>> x = [1, 2, 3, 4, 5]>>> x[::][1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>> x[1:3][2, 3]>>> x[1:-1]

[1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>> x[1:3][2, 3]>>> x[1:-1][2, 3, 4]>>>

[1, 2, 3, 4, 5]>>> x[:][1, 2, 3, 4, 5]>>> x[1:3][2, 3]>>> x[1:-1][2, 3, 4]>>> x[::2]

[1, 2, 3, 4, 5]>>> x[1:3][2, 3]>>> x[1:-1][2, 3, 4]>>> x[::2][1, 3, 5]>>>

[1, 2, 3, 4, 5]>>> x[1:3][2, 3]>>> x[1:-1][2, 3, 4]>>> x[::2][1, 3, 5]>>> x[::-1]

[2, 3]>>> x[1:-1][2, 3, 4]>>> x[::2][1, 3, 5]>>> x[::-1][5, 4, 3, 2, 1]>>>

Slice

[start:end(:step)]

[0:length(:1)]

default value

Page 261: Python @NCKU CSIE

>>>

length of list

len(list)

Page 262: Python @NCKU CSIE

>>>>>> x = [1, 2, 3, 4, 5]

length of list

len(list)

Page 263: Python @NCKU CSIE

>>>>>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>>

length of list

len(list)

Page 264: Python @NCKU CSIE

>>>>>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>> >>> x = [1, 2, 3, 4, 5]>>> len(x)

length of list

len(list)

Page 265: Python @NCKU CSIE

>>>>>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>> >>> x = [1, 2, 3, 4, 5]>>> len(x)>>> x = [1, 2, 3, 4, 5]>>> len(x)5>>>

length of list

len(list)

Page 266: Python @NCKU CSIE

>>>>>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>> >>> x = [1, 2, 3, 4, 5]>>> len(x)>>> x = [1, 2, 3, 4, 5]>>> len(x)5>>>

>>> x = [1, 2, 3, 4, 5]>>> len(x)5>>> len(x[::2])

length of list

len(list)

Page 267: Python @NCKU CSIE

>>>>>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>> >>> x = [1, 2, 3, 4, 5]>>> len(x)>>> x = [1, 2, 3, 4, 5]>>> len(x)5>>>

>>> x = [1, 2, 3, 4, 5]>>> len(x)5>>> len(x[::2])

>>> x = [1, 2, 3, 4, 5]>>> len(x)5>>> len(x[::2])3>>>

length of list

len(list)

Page 268: Python @NCKU CSIE

Tuple

Immutable List

>>>

Page 269: Python @NCKU CSIE

Tuple

Immutable List

>>> >>> (1, ‘aaa’, 2)

Page 270: Python @NCKU CSIE

Tuple

Immutable List

>>> >>> (1, ‘aaa’, 2)>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>>

Page 271: Python @NCKU CSIE

Tuple

Immutable List

>>> >>> (1, ‘aaa’, 2)>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>>

>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>> 1, ‘aaa’, 2

Page 272: Python @NCKU CSIE

Tuple

Immutable List

>>> >>> (1, ‘aaa’, 2)>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>>

>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>> 1, ‘aaa’, 2

>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>> 1, ‘aaa’, 2(1, ‘aaa’, 2)>>>

Page 273: Python @NCKU CSIE

Tuple

Immutable List

>>> >>> (1, ‘aaa’, 2)>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>>

>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>> 1, ‘aaa’, 2

>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>> 1, ‘aaa’, 2(1, ‘aaa’, 2)>>>

>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>> 1, ‘aaa’, 2(1, ‘aaa’, 2)>>> x = (1, ‘aaa’, 2)

Page 274: Python @NCKU CSIE

Tuple

Immutable List

>>> >>> (1, ‘aaa’, 2)>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>>

>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>> 1, ‘aaa’, 2

>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>> 1, ‘aaa’, 2(1, ‘aaa’, 2)>>>

>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>> 1, ‘aaa’, 2(1, ‘aaa’, 2)>>> x = (1, ‘aaa’, 2)

>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>> 1, ‘aaa’, 2(1, ‘aaa’, 2)>>> x = (1, ‘aaa’, 2)>>>

Page 275: Python @NCKU CSIE

Tuple

Immutable List

>>> >>> (1, ‘aaa’, 2)>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>>

>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>> 1, ‘aaa’, 2

>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>> 1, ‘aaa’, 2(1, ‘aaa’, 2)>>>

>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>> 1, ‘aaa’, 2(1, ‘aaa’, 2)>>> x = (1, ‘aaa’, 2)

>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>> 1, ‘aaa’, 2(1, ‘aaa’, 2)>>> x = (1, ‘aaa’, 2)>>>

>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>> 1, ‘aaa’, 2(1, ‘aaa’, 2)>>> x = (1, ‘aaa’, 2)>>> x[1] = 3

Page 276: Python @NCKU CSIE

Tuple

Immutable List

>>> >>> (1, ‘aaa’, 2)>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>>

>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>> 1, ‘aaa’, 2

>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>> 1, ‘aaa’, 2(1, ‘aaa’, 2)>>>

>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>> 1, ‘aaa’, 2(1, ‘aaa’, 2)>>> x = (1, ‘aaa’, 2)

>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>> 1, ‘aaa’, 2(1, ‘aaa’, 2)>>> x = (1, ‘aaa’, 2)>>>

>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>> 1, ‘aaa’, 2(1, ‘aaa’, 2)>>> x = (1, ‘aaa’, 2)>>> x[1] = 3

>>> x[1] = 3Traceback (most recent call last): File "<input>", line 1, in <module>TypeError: 'tuple' object does not support item assignment

Page 277: Python @NCKU CSIE

Tuple

Immutable List

>>> >>> (1, ‘aaa’, 2)>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>>

>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>> 1, ‘aaa’, 2

>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>> 1, ‘aaa’, 2(1, ‘aaa’, 2)>>>

>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>> 1, ‘aaa’, 2(1, ‘aaa’, 2)>>> x = (1, ‘aaa’, 2)

>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>> 1, ‘aaa’, 2(1, ‘aaa’, 2)>>> x = (1, ‘aaa’, 2)>>>

>>> (1, ‘aaa’, 2)(1, ‘aaa’, 2)>>> 1, ‘aaa’, 2(1, ‘aaa’, 2)>>> x = (1, ‘aaa’, 2)>>> x[1] = 3

>>> x[1] = 3Traceback (most recent call last): File "<input>", line 1, in <module>TypeError: 'tuple' object does not support item assignment

Traceback (most recent call last): File "<input>", line 1, in <module>TypeError: 'tuple' object does not support item assignment>>>

Page 278: Python @NCKU CSIE

>>>

Initialization / Conversion

Page 279: Python @NCKU CSIE

>>> >>> tuple([1, 2, 3])

Initialization / Conversion

Page 280: Python @NCKU CSIE

>>> >>> tuple([1, 2, 3])>>> tuple([1, 2, 3])(1, 2, 3)>>>

Initialization / Conversion

Page 281: Python @NCKU CSIE

>>>

Access Element

Page 282: Python @NCKU CSIE

>>>>>> x = (1, 2, 3)

Access Element

Page 283: Python @NCKU CSIE

>>>>>> x = (1, 2, 3)

Access Element

>>> x = (1, 2, 3)>>>

Page 284: Python @NCKU CSIE

>>>>>> x = (1, 2, 3)

Access Element

>>> x = (1, 2, 3)>>> >>> x = (1, 2, 3)>>> x[1]

Page 285: Python @NCKU CSIE

>>>>>> x = (1, 2, 3)

Access Element

>>> x = (1, 2, 3)>>> >>> x = (1, 2, 3)>>> x[1]>>> x = (1, 2, 3)>>> x[1]2>>>

Page 286: Python @NCKU CSIE

>>>>>> x = (1, 2, 3)

Access Element

>>> x = (1, 2, 3)>>> >>> x = (1, 2, 3)>>> x[1]>>> x = (1, 2, 3)>>> x[1]2>>>

>>> x = (1, 2, 3)>>> x[1]2>>> a, b, c = x

Page 287: Python @NCKU CSIE

>>>>>> x = (1, 2, 3)

Access Element

>>> x = (1, 2, 3)>>> >>> x = (1, 2, 3)>>> x[1]>>> x = (1, 2, 3)>>> x[1]2>>>

>>> x = (1, 2, 3)>>> x[1]2>>> a, b, c = x

>>> x = (1, 2, 3)>>> x[1]2>>> a, b, c = x>>>

Page 288: Python @NCKU CSIE

>>>>>> x = (1, 2, 3)

Access Element

>>> x = (1, 2, 3)>>> >>> x = (1, 2, 3)>>> x[1]>>> x = (1, 2, 3)>>> x[1]2>>>

>>> x = (1, 2, 3)>>> x[1]2>>> a, b, c = x

>>> x = (1, 2, 3)>>> x[1]2>>> a, b, c = x>>>

>>> x = (1, 2, 3)>>> x[1]2>>> a, b, c = x>>> a

Page 289: Python @NCKU CSIE

>>>>>> x = (1, 2, 3)

Access Element

>>> x = (1, 2, 3)>>> >>> x = (1, 2, 3)>>> x[1]>>> x = (1, 2, 3)>>> x[1]2>>>

>>> x = (1, 2, 3)>>> x[1]2>>> a, b, c = x

>>> x = (1, 2, 3)>>> x[1]2>>> a, b, c = x>>>

>>> x = (1, 2, 3)>>> x[1]2>>> a, b, c = x>>> a

>>> x = (1, 2, 3)>>> x[1]2>>> a, b, c = x>>> a1>>>

Page 290: Python @NCKU CSIE

>>>>>> x = (1, 2, 3)

Access Element

>>> x = (1, 2, 3)>>> >>> x = (1, 2, 3)>>> x[1]>>> x = (1, 2, 3)>>> x[1]2>>>

>>> x = (1, 2, 3)>>> x[1]2>>> a, b, c = x

>>> x = (1, 2, 3)>>> x[1]2>>> a, b, c = x>>>

>>> x = (1, 2, 3)>>> x[1]2>>> a, b, c = x>>> a

>>> x = (1, 2, 3)>>> x[1]2>>> a, b, c = x>>> a1>>>

>>> x = (1, 2, 3)>>> x[1]2>>> a, b, c = x>>> a1>>> b

Page 291: Python @NCKU CSIE

>>>>>> x = (1, 2, 3)

Access Element

>>> x = (1, 2, 3)>>> >>> x = (1, 2, 3)>>> x[1]>>> x = (1, 2, 3)>>> x[1]2>>>

>>> x = (1, 2, 3)>>> x[1]2>>> a, b, c = x

>>> x = (1, 2, 3)>>> x[1]2>>> a, b, c = x>>>

>>> x = (1, 2, 3)>>> x[1]2>>> a, b, c = x>>> a

>>> x = (1, 2, 3)>>> x[1]2>>> a, b, c = x>>> a1>>>

>>> x = (1, 2, 3)>>> x[1]2>>> a, b, c = x>>> a1>>> b

>>> x[1]2>>> a, b, c = x>>> a1>>> b2>>>

Page 292: Python @NCKU CSIE

>>>>>> x = (1, 2, 3)

Access Element

>>> x = (1, 2, 3)>>> >>> x = (1, 2, 3)>>> x[1]>>> x = (1, 2, 3)>>> x[1]2>>>

>>> x = (1, 2, 3)>>> x[1]2>>> a, b, c = x

>>> x = (1, 2, 3)>>> x[1]2>>> a, b, c = x>>>

>>> x = (1, 2, 3)>>> x[1]2>>> a, b, c = x>>> a

>>> x = (1, 2, 3)>>> x[1]2>>> a, b, c = x>>> a1>>>

>>> x = (1, 2, 3)>>> x[1]2>>> a, b, c = x>>> a1>>> b

>>> x[1]2>>> a, b, c = x>>> a1>>> b2>>>

>>> x[1]2>>> a, b, c = x>>> a1>>> b2>>> c

Page 293: Python @NCKU CSIE

>>>>>> x = (1, 2, 3)

Access Element

>>> x = (1, 2, 3)>>> >>> x = (1, 2, 3)>>> x[1]>>> x = (1, 2, 3)>>> x[1]2>>>

>>> x = (1, 2, 3)>>> x[1]2>>> a, b, c = x

>>> x = (1, 2, 3)>>> x[1]2>>> a, b, c = x>>>

>>> x = (1, 2, 3)>>> x[1]2>>> a, b, c = x>>> a

>>> x = (1, 2, 3)>>> x[1]2>>> a, b, c = x>>> a1>>>

>>> x = (1, 2, 3)>>> x[1]2>>> a, b, c = x>>> a1>>> b

>>> x[1]2>>> a, b, c = x>>> a1>>> b2>>>

>>> x[1]2>>> a, b, c = x>>> a1>>> b2>>> c

>>> a, b, c = x>>> a1>>> b2>>> c3>>>

Page 294: Python @NCKU CSIE

>>>

length of tuple

len(tuple)

Page 295: Python @NCKU CSIE

>>>>>> x = 1, 2, 3, 4, 5

length of tuple

len(tuple)

Page 296: Python @NCKU CSIE

>>>>>> x = 1, 2, 3, 4, 5>>> x = 1, 2, 3, 4, 5>>>

length of tuple

len(tuple)

Page 297: Python @NCKU CSIE

>>>>>> x = 1, 2, 3, 4, 5>>> x = 1, 2, 3, 4, 5>>> >>> x = 1, 2, 3, 4, 5>>> len(x)

length of tuple

len(tuple)

Page 298: Python @NCKU CSIE

>>>>>> x = 1, 2, 3, 4, 5>>> x = 1, 2, 3, 4, 5>>> >>> x = 1, 2, 3, 4, 5>>> len(x)>>> x = 1, 2, 3, 4, 5>>> len(x)5>>>

length of tuple

len(tuple)

Page 299: Python @NCKU CSIE

Dictionary

>>> key-value relation

key value

Page 300: Python @NCKU CSIE

Dictionary

>>> key-value relation

key value

Page 301: Python @NCKU CSIE

Dictionary

>>> key-value relation

key value

>>> x = dict()

Page 302: Python @NCKU CSIE

Dictionary

>>> key-value relation

key value

>>> x = dict()>>> x = dict()>>>

Page 303: Python @NCKU CSIE

Dictionary

>>> key-value relation

key value

>>> x = dict()>>> x = dict()>>>>>> x = dict()>>> x[‘abc’] = 123

Page 304: Python @NCKU CSIE

Dictionary

>>> key-value relation

key value

>>> x = dict()>>> x = dict()>>>>>> x = dict()>>> x[‘abc’] = 123>>> x = dict()>>> x[‘abc’] = 123>>>

Page 305: Python @NCKU CSIE

Dictionary

>>> key-value relation

key value

>>> x = dict()>>> x = dict()>>>>>> x = dict()>>> x[‘abc’] = 123>>> x = dict()>>> x[‘abc’] = 123>>>

>>> x = dict()>>> x[‘abc’] = 123>>> x[111] = ‘aaa’

Page 306: Python @NCKU CSIE

Dictionary

>>> key-value relation

key value

>>> x = dict()>>> x = dict()>>>>>> x = dict()>>> x[‘abc’] = 123>>> x = dict()>>> x[‘abc’] = 123>>>

>>> x = dict()>>> x[‘abc’] = 123>>> x[111] = ‘aaa’

>>> x = dict()>>> x[‘abc’] = 123>>> x[111] = ‘aaa’>>>

Page 307: Python @NCKU CSIE

Dictionary

>>> key-value relation

key value

>>> x = dict()>>> x = dict()>>>>>> x = dict()>>> x[‘abc’] = 123>>> x = dict()>>> x[‘abc’] = 123>>>

>>> x = dict()>>> x[‘abc’] = 123>>> x[111] = ‘aaa’

>>> x = dict()>>> x[‘abc’] = 123>>> x[111] = ‘aaa’>>>

>>> x = dict()>>> x[‘abc’] = 123>>> x[111] = ‘aaa’>>> x

Page 308: Python @NCKU CSIE

Dictionary

>>> key-value relation

key value

>>> x = dict()>>> x = dict()>>>>>> x = dict()>>> x[‘abc’] = 123>>> x = dict()>>> x[‘abc’] = 123>>>

>>> x = dict()>>> x[‘abc’] = 123>>> x[111] = ‘aaa’

>>> x = dict()>>> x[‘abc’] = 123>>> x[111] = ‘aaa’>>>

>>> x = dict()>>> x[‘abc’] = 123>>> x[111] = ‘aaa’>>> x

>>> x = dict()>>> x[‘abc’] = 123>>> x[111] = ‘aaa’>>> x{‘abc’: 123, 111: ‘aaa’}>>>

Page 309: Python @NCKU CSIE

Dictionary

>>> key-value relation

key value

>>> x = dict()>>> x = dict()>>>>>> x = dict()>>> x[‘abc’] = 123>>> x = dict()>>> x[‘abc’] = 123>>>

>>> x = dict()>>> x[‘abc’] = 123>>> x[111] = ‘aaa’

>>> x = dict()>>> x[‘abc’] = 123>>> x[111] = ‘aaa’>>>

>>> x = dict()>>> x[‘abc’] = 123>>> x[111] = ‘aaa’>>> x

>>> x = dict()>>> x[‘abc’] = 123>>> x[111] = ‘aaa’>>> x{‘abc’: 123, 111: ‘aaa’}>>>

>>> x = dict()>>> x[‘abc’] = 123>>> x[111] = ‘aaa’>>> x{‘abc’: 123, 111: ‘aaa’}>>> {1: 20, 2: 30}

Page 310: Python @NCKU CSIE

Dictionary

>>> key-value relation

key value

>>> x = dict()>>> x = dict()>>>>>> x = dict()>>> x[‘abc’] = 123>>> x = dict()>>> x[‘abc’] = 123>>>

>>> x = dict()>>> x[‘abc’] = 123>>> x[111] = ‘aaa’

>>> x = dict()>>> x[‘abc’] = 123>>> x[111] = ‘aaa’>>>

>>> x = dict()>>> x[‘abc’] = 123>>> x[111] = ‘aaa’>>> x

>>> x = dict()>>> x[‘abc’] = 123>>> x[111] = ‘aaa’>>> x{‘abc’: 123, 111: ‘aaa’}>>>

>>> x = dict()>>> x[‘abc’] = 123>>> x[111] = ‘aaa’>>> x{‘abc’: 123, 111: ‘aaa’}>>> {1: 20, 2: 30}

>>> x = dict()>>> x[‘abc’] = 123>>> x[111] = ‘aaa’>>> x{‘abc’: 123, 111: ‘aaa’}>>> {1: 20, 2: 30}{1: 20, 2: 30}>>>

Page 311: Python @NCKU CSIE

Initialization / Conversion

>>>

Page 312: Python @NCKU CSIE

Initialization / Conversion

>>> >>> dict()

Page 313: Python @NCKU CSIE

Initialization / Conversion

>>> >>> dict()>>> dict(){}>>>

Page 314: Python @NCKU CSIE

Initialization / Conversion

>>> >>> dict()>>> dict(){}>>>

>>> dict(){}>>> dict(one=1, two=2)

Page 315: Python @NCKU CSIE

Initialization / Conversion

>>> >>> dict()>>> dict(){}>>>

>>> dict(){}>>> dict(one=1, two=2)

>>> dict(){}>>> dict(one=1, two=2){‘one’: 1, ‘two’: 2}>>>

Page 316: Python @NCKU CSIE

Initialization / Conversion

>>> >>> dict()>>> dict(){}>>>

>>> dict(){}>>> dict(one=1, two=2)

>>> dict(){}>>> dict(one=1, two=2){‘one’: 1, ‘two’: 2}>>>

>>> dict(){}>>> dict(one=1, two=2){‘one’: 1, ‘two’: 2}>>> dict([('two', 2),

>>> dict(){}>>> dict(one=1, two=2){‘one’: 1, ‘two’: 2}>>> dict([('two', 2), (‘one’: 1)])

Page 317: Python @NCKU CSIE

Initialization / Conversion

>>> >>> dict()>>> dict(){}>>>

>>> dict(){}>>> dict(one=1, two=2)

>>> dict(){}>>> dict(one=1, two=2){‘one’: 1, ‘two’: 2}>>>

>>> dict(){}>>> dict(one=1, two=2){‘one’: 1, ‘two’: 2}>>> dict([('two', 2),

>>> dict(){}>>> dict(one=1, two=2){‘one’: 1, ‘two’: 2}>>> dict([('two', 2), (‘one’: 1)])

>>> dict(){}>>> dict(one=1, two=2){‘one’: 1, ‘two’: 2}>>> dict([('two', 2), (‘one’: 1)]){‘one’: 1, ‘two’: 2}>>>

Page 318: Python @NCKU CSIE

Initialization / Conversion

>>> >>> dict()>>> dict(){}>>>

>>> dict(){}>>> dict(one=1, two=2)

>>> dict(){}>>> dict(one=1, two=2){‘one’: 1, ‘two’: 2}>>>

>>> dict(){}>>> dict(one=1, two=2){‘one’: 1, ‘two’: 2}>>> dict([('two', 2),

>>> dict(){}>>> dict(one=1, two=2){‘one’: 1, ‘two’: 2}>>> dict([('two', 2), (‘one’: 1)])

>>> dict(){}>>> dict(one=1, two=2){‘one’: 1, ‘two’: 2}>>> dict([('two', 2), (‘one’: 1)]){‘one’: 1, ‘two’: 2}>>>

>>> dict(){}>>> dict(one=1, two=2){‘one’: 1, ‘two’: 2}>>> dict([('two', 2), (‘one’: 1)]){‘one’: 1, ‘two’: 2}>>> dict({‘one’: 1,

{}>>> dict(one=1, two=2){‘one’: 1, ‘two’: 2}>>> dict([('two', 2), (‘one’: 1)]){‘one’: 1, ‘two’: 2}>>> dict({‘one’: 1,

{}>>> dict(one=1, two=2){‘one’: 1, ‘two’: 2}>>> dict([('two', 2), (‘one’: 1)]){‘one’: 1, ‘two’: 2}>>> dict({‘one’: 1, ‘two’: 2})

Page 319: Python @NCKU CSIE

Initialization / Conversion

>>> >>> dict()>>> dict(){}>>>

>>> dict(){}>>> dict(one=1, two=2)

>>> dict(){}>>> dict(one=1, two=2){‘one’: 1, ‘two’: 2}>>>

>>> dict(){}>>> dict(one=1, two=2){‘one’: 1, ‘two’: 2}>>> dict([('two', 2),

>>> dict(){}>>> dict(one=1, two=2){‘one’: 1, ‘two’: 2}>>> dict([('two', 2), (‘one’: 1)])

>>> dict(){}>>> dict(one=1, two=2){‘one’: 1, ‘two’: 2}>>> dict([('two', 2), (‘one’: 1)]){‘one’: 1, ‘two’: 2}>>>

>>> dict(){}>>> dict(one=1, two=2){‘one’: 1, ‘two’: 2}>>> dict([('two', 2), (‘one’: 1)]){‘one’: 1, ‘two’: 2}>>> dict({‘one’: 1,

{}>>> dict(one=1, two=2){‘one’: 1, ‘two’: 2}>>> dict([('two', 2), (‘one’: 1)]){‘one’: 1, ‘two’: 2}>>> dict({‘one’: 1,

{}>>> dict(one=1, two=2){‘one’: 1, ‘two’: 2}>>> dict([('two', 2), (‘one’: 1)]){‘one’: 1, ‘two’: 2}>>> dict({‘one’: 1, ‘two’: 2})

{‘one’: 1, ‘two’: 2}>>> dict([('two', 2), (‘one’: 1)]){‘one’: 1, ‘two’: 2}>>> dict({‘one’: 1, ‘two’: 2}){‘one’: 1, ‘two’: 2}>>>

Page 320: Python @NCKU CSIE

>>>

number of dictionary

len(dict)

Page 321: Python @NCKU CSIE

>>>>>> x = {‘one’: 1,

number of dictionary

len(dict)>>> x = {‘one’: 1, ‘two’: 2}

Page 322: Python @NCKU CSIE

>>>>>> x = {‘one’: 1,

number of dictionary

len(dict)>>> x = {‘one’: 1, ‘two’: 2}>>> x = {‘one’: 1, ‘two’: 2}>>>

Page 323: Python @NCKU CSIE

>>>>>> x = {‘one’: 1,

number of dictionary

len(dict)>>> x = {‘one’: 1, ‘two’: 2}>>> x = {‘one’: 1, ‘two’: 2}>>>

>>> x = {‘one’: 1, ‘two’: 2}>>> len(x)

Page 324: Python @NCKU CSIE

>>>>>> x = {‘one’: 1,

number of dictionary

len(dict)>>> x = {‘one’: 1, ‘two’: 2}>>> x = {‘one’: 1, ‘two’: 2}>>>

>>> x = {‘one’: 1, ‘two’: 2}>>> len(x)

>>> x = {‘one’: 1, ‘two’: 2}>>> len(x)2>>>

Page 325: Python @NCKU CSIE

Control

Page 326: Python @NCKU CSIE

Condition>>>

Page 327: Python @NCKU CSIE

Condition>>> >>> x = 100

Page 328: Python @NCKU CSIE

Condition>>> >>> x = 100>>> x = 100>>>

Page 329: Python @NCKU CSIE

Condition>>> >>> x = 100>>> x = 100>>>>>> x = 100>>> if x > 100:

Page 330: Python @NCKU CSIE

Condition>>> >>> x = 100>>> x = 100>>>>>> x = 100>>> if x > 100:>>> x = 100>>> if x > 100:...

Page 331: Python @NCKU CSIE

Condition>>> >>> x = 100>>> x = 100>>>>>> x = 100>>> if x > 100:>>> x = 100>>> if x > 100:...

>>> x = 100>>> if x > 100:... x = x + 10

Page 332: Python @NCKU CSIE

Condition>>> >>> x = 100>>> x = 100>>>>>> x = 100>>> if x > 100:>>> x = 100>>> if x > 100:...

>>> x = 100>>> if x > 100:... x = x + 10

>>> x = 100>>> if x > 100:... x = x + 10...

Page 333: Python @NCKU CSIE

Condition>>> >>> x = 100>>> x = 100>>>>>> x = 100>>> if x > 100:>>> x = 100>>> if x > 100:...

>>> x = 100>>> if x > 100:... x = x + 10

>>> x = 100>>> if x > 100:... x = x + 10...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:

Page 334: Python @NCKU CSIE

Condition>>> >>> x = 100>>> x = 100>>>>>> x = 100>>> if x > 100:>>> x = 100>>> if x > 100:...

>>> x = 100>>> if x > 100:... x = x + 10

>>> x = 100>>> if x > 100:... x = x + 10...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:...

Page 335: Python @NCKU CSIE

Condition>>> >>> x = 100>>> x = 100>>>>>> x = 100>>> if x > 100:>>> x = 100>>> if x > 100:...

>>> x = 100>>> if x > 100:... x = x + 10

>>> x = 100>>> if x > 100:... x = x + 10...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10

Page 336: Python @NCKU CSIE

Condition>>> >>> x = 100>>> x = 100>>>>>> x = 100>>> if x > 100:>>> x = 100>>> if x > 100:...

>>> x = 100>>> if x > 100:... x = x + 10

>>> x = 100>>> if x > 100:... x = x + 10...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10...

Page 337: Python @NCKU CSIE

Condition>>> >>> x = 100>>> x = 100>>>>>> x = 100>>> if x > 100:>>> x = 100>>> if x > 100:...

>>> x = 100>>> if x > 100:... x = x + 10

>>> x = 100>>> if x > 100:... x = x + 10...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:

Page 338: Python @NCKU CSIE

Condition>>> >>> x = 100>>> x = 100>>>>>> x = 100>>> if x > 100:>>> x = 100>>> if x > 100:...

>>> x = 100>>> if x > 100:... x = x + 10

>>> x = 100>>> if x > 100:... x = x + 10...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:...

Page 339: Python @NCKU CSIE

Condition>>> >>> x = 100>>> x = 100>>>>>> x = 100>>> if x > 100:>>> x = 100>>> if x > 100:...

>>> x = 100>>> if x > 100:... x = x + 10

>>> x = 100>>> if x > 100:... x = x + 10...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0

Page 340: Python @NCKU CSIE

Condition>>> >>> x = 100>>> x = 100>>>>>> x = 100>>> if x > 100:>>> x = 100>>> if x > 100:...

>>> x = 100>>> if x > 100:... x = x + 10

>>> x = 100>>> if x > 100:... x = x + 10...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0...

Page 341: Python @NCKU CSIE

Condition>>> >>> x = 100>>> x = 100>>>>>> x = 100>>> if x > 100:>>> x = 100>>> if x > 100:...

>>> x = 100>>> if x > 100:... x = x + 10

>>> x = 100>>> if x > 100:... x = x + 10...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0...>>>

Page 342: Python @NCKU CSIE

Condition>>> >>> x = 100>>> x = 100>>>>>> x = 100>>> if x > 100:>>> x = 100>>> if x > 100:...

>>> x = 100>>> if x > 100:... x = x + 10

>>> x = 100>>> if x > 100:... x = x + 10...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0...>>>

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0...>>> x

Page 343: Python @NCKU CSIE

Condition>>> >>> x = 100>>> x = 100>>>>>> x = 100>>> if x > 100:>>> x = 100>>> if x > 100:...

>>> x = 100>>> if x > 100:... x = x + 10

>>> x = 100>>> if x > 100:... x = x + 10...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0...>>>

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0...>>> x

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0...>>> x0>>>

Page 344: Python @NCKU CSIE

Condition>>> >>> x = 100>>> x = 100>>>>>> x = 100>>> if x > 100:>>> x = 100>>> if x > 100:...

>>> x = 100>>> if x > 100:... x = x + 10

>>> x = 100>>> if x > 100:... x = x + 10...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0...>>>

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0...>>> x

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0...>>> x0>>>

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0...>>> x0>>>

Page 345: Python @NCKU CSIE

Condition>>> >>> x = 100>>> x = 100>>>>>> x = 100>>> if x > 100:>>> x = 100>>> if x > 100:...

>>> x = 100>>> if x > 100:... x = x + 10

>>> x = 100>>> if x > 100:... x = x + 10...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0...>>>

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0...>>> x

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0...>>> x0>>>

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0...>>> x0>>>

else if

Page 346: Python @NCKU CSIE

Condition>>> >>> x = 100>>> x = 100>>>>>> x = 100>>> if x > 100:>>> x = 100>>> if x > 100:...

>>> x = 100>>> if x > 100:... x = x + 10

>>> x = 100>>> if x > 100:... x = x + 10...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0...

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0...>>>

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0...>>> x

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0...>>> x0>>>

>>> x = 100>>> if x > 100:... x = x + 10... elif x < 100:... x = x - 10... else:... x = 0...>>> x0>>>

else if

no switch statement in Python

Page 347: Python @NCKU CSIE

>>>

Loop

Page 348: Python @NCKU CSIE

>>> >>> i = 0

Loop

Page 349: Python @NCKU CSIE

>>> >>> i = 0>>> i = 0>>>

Loop

Page 350: Python @NCKU CSIE

>>> >>> i = 0>>> i = 0>>>>>> i = 0>>> while i < 3:

Loop

Page 351: Python @NCKU CSIE

>>> >>> i = 0>>> i = 0>>>>>> i = 0>>> while i < 3:>>> i = 0>>> while i < 3:...

Loop

Page 352: Python @NCKU CSIE

>>> >>> i = 0>>> i = 0>>>>>> i = 0>>> while i < 3:>>> i = 0>>> while i < 3:...

>>> i = 0>>> while i < 3:... i = i + 1

Loop

Page 353: Python @NCKU CSIE

>>> >>> i = 0>>> i = 0>>>>>> i = 0>>> while i < 3:>>> i = 0>>> while i < 3:...

>>> i = 0>>> while i < 3:... i = i + 1

>>> i = 0>>> while i < 3:... i = i + 1...

Loop

Page 354: Python @NCKU CSIE

>>> >>> i = 0>>> i = 0>>>>>> i = 0>>> while i < 3:>>> i = 0>>> while i < 3:...

>>> i = 0>>> while i < 3:... i = i + 1

>>> i = 0>>> while i < 3:... i = i + 1...

>>> i = 0>>> while i < 3:... i = i + 1... print i

Loop

Page 355: Python @NCKU CSIE

>>> >>> i = 0>>> i = 0>>>>>> i = 0>>> while i < 3:>>> i = 0>>> while i < 3:...

>>> i = 0>>> while i < 3:... i = i + 1

>>> i = 0>>> while i < 3:... i = i + 1...

>>> i = 0>>> while i < 3:... i = i + 1... print i

>>> i = 0>>> while i < 3:... i = i + 1... print i...

Loop

Page 356: Python @NCKU CSIE

>>> >>> i = 0>>> i = 0>>>>>> i = 0>>> while i < 3:>>> i = 0>>> while i < 3:...

>>> i = 0>>> while i < 3:... i = i + 1

>>> i = 0>>> while i < 3:... i = i + 1...

>>> i = 0>>> while i < 3:... i = i + 1... print i

>>> i = 0>>> while i < 3:... i = i + 1... print i...

>>> i = 0>>> while i < 3:... i = i + 1... print i...123>>>

Loop

Page 357: Python @NCKU CSIE

>>> >>> i = 0>>> i = 0>>>>>> i = 0>>> while i < 3:>>> i = 0>>> while i < 3:...

>>> i = 0>>> while i < 3:... i = i + 1

>>> i = 0>>> while i < 3:... i = i + 1...

>>> i = 0>>> while i < 3:... i = i + 1... print i

>>> i = 0>>> while i < 3:... i = i + 1... print i...

>>> i = 0>>> while i < 3:... i = i + 1... print i...123>>>

no do-while statement in Python

Loop

Page 358: Python @NCKU CSIE

>>>

Traversal Sequence

Page 359: Python @NCKU CSIE

>>> >>> x = [1, 2, 3, 4, 5]

Traversal Sequence

Page 360: Python @NCKU CSIE

>>> >>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>>

Traversal Sequence

Page 361: Python @NCKU CSIE

>>> >>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>> >>> x = [1, 2, 3, 4, 5]>>> for i in x:

Traversal Sequence

Page 362: Python @NCKU CSIE

>>> >>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>> >>> x = [1, 2, 3, 4, 5]>>> for i in x:>>> x = [1, 2, 3, 4, 5]>>> for i in x:...

Traversal Sequence

Page 363: Python @NCKU CSIE

>>> >>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>> >>> x = [1, 2, 3, 4, 5]>>> for i in x:>>> x = [1, 2, 3, 4, 5]>>> for i in x:...

>>> x = [1, 2, 3, 4, 5]>>> for i in x:... print i

Traversal Sequence

Page 364: Python @NCKU CSIE

>>> >>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>> >>> x = [1, 2, 3, 4, 5]>>> for i in x:>>> x = [1, 2, 3, 4, 5]>>> for i in x:...

>>> x = [1, 2, 3, 4, 5]>>> for i in x:... print i

>>> x = [1, 2, 3, 4, 5]>>> for i in x:... print i...

Traversal Sequence

Page 365: Python @NCKU CSIE

>>> >>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>> >>> x = [1, 2, 3, 4, 5]>>> for i in x:>>> x = [1, 2, 3, 4, 5]>>> for i in x:...

>>> x = [1, 2, 3, 4, 5]>>> for i in x:... print i

>>> x = [1, 2, 3, 4, 5]>>> for i in x:... print i...

>>> x = [1, 2, 3, 4, 5]>>> for i in x:... print i...12345>>>

Traversal Sequence

Page 366: Python @NCKU CSIE

>>> >>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>> >>> x = [1, 2, 3, 4, 5]>>> for i in x:>>> x = [1, 2, 3, 4, 5]>>> for i in x:...

>>> x = [1, 2, 3, 4, 5]>>> for i in x:... print i

>>> x = [1, 2, 3, 4, 5]>>> for i in x:... print i...

>>> x = [1, 2, 3, 4, 5]>>> for i in x:... print i...12345>>>

Traversal Sequence>>> x = [1, 2, 3, 4, 5]>>> for i in x:... print i...12345>>>

Page 367: Python @NCKU CSIE

>>> >>> x = [1, 2, 3, 4, 5]>>> x = [1, 2, 3, 4, 5]>>> >>> x = [1, 2, 3, 4, 5]>>> for i in x:>>> x = [1, 2, 3, 4, 5]>>> for i in x:...

>>> x = [1, 2, 3, 4, 5]>>> for i in x:... print i

>>> x = [1, 2, 3, 4, 5]>>> for i in x:... print i...

>>> x = [1, 2, 3, 4, 5]>>> for i in x:... print i...12345>>>

Traversal Sequence>>> x = [1, 2, 3, 4, 5]>>> for i in x:... print i...12345>>>

must be a iterable object

Page 368: Python @NCKU CSIE

>>>

Addition for Loopcontinue skip remaining statement and

continue loop

Page 369: Python @NCKU CSIE

>>> >>> for i in range(5):

Addition for Loopcontinue skip remaining statement and

continue loop

Page 370: Python @NCKU CSIE

>>> >>> for i in range(5):>>> for i in range(5):...

Addition for Loopcontinue skip remaining statement and

continue loop

Page 371: Python @NCKU CSIE

>>> >>> for i in range(5):>>> for i in range(5):...>>> for i in range(5):... if i == 2:

Addition for Loopcontinue skip remaining statement and

continue loop

Page 372: Python @NCKU CSIE

>>> >>> for i in range(5):>>> for i in range(5):...>>> for i in range(5):... if i == 2:>>> for i in range(5):... if i == 2:...

Addition for Loopcontinue skip remaining statement and

continue loop

Page 373: Python @NCKU CSIE

>>> >>> for i in range(5):>>> for i in range(5):...>>> for i in range(5):... if i == 2:>>> for i in range(5):... if i == 2:...

>>> for i in range(5):... if i == 2:... continue

Addition for Loopcontinue skip remaining statement and

continue loop

Page 374: Python @NCKU CSIE

>>> >>> for i in range(5):>>> for i in range(5):...>>> for i in range(5):... if i == 2:>>> for i in range(5):... if i == 2:...

>>> for i in range(5):... if i == 2:... continue

>>> for i in range(5):... if i == 2:... continue...

Addition for Loopcontinue skip remaining statement and

continue loop

Page 375: Python @NCKU CSIE

>>> >>> for i in range(5):>>> for i in range(5):...>>> for i in range(5):... if i == 2:>>> for i in range(5):... if i == 2:...

>>> for i in range(5):... if i == 2:... continue

>>> for i in range(5):... if i == 2:... continue...

>>> for i in range(5):... if i == 2:... continue... print i

Addition for Loopcontinue skip remaining statement and

continue loop

Page 376: Python @NCKU CSIE

>>> >>> for i in range(5):>>> for i in range(5):...>>> for i in range(5):... if i == 2:>>> for i in range(5):... if i == 2:...

>>> for i in range(5):... if i == 2:... continue

>>> for i in range(5):... if i == 2:... continue...

>>> for i in range(5):... if i == 2:... continue... print i

>>> for i in range(5):... if i == 2:... continue... print i...

Addition for Loopcontinue skip remaining statement and

continue loop

Page 377: Python @NCKU CSIE

>>> >>> for i in range(5):>>> for i in range(5):...>>> for i in range(5):... if i == 2:>>> for i in range(5):... if i == 2:...

>>> for i in range(5):... if i == 2:... continue

>>> for i in range(5):... if i == 2:... continue...

>>> for i in range(5):... if i == 2:... continue... print i

>>> for i in range(5):... if i == 2:... continue... print i...

... if i == 2:

... continue

... print i

... 0134>>>

Addition for Loopcontinue skip remaining statement and

continue loop

Page 378: Python @NCKU CSIE

>>>

Addition for Loopbreak exit from loop

Page 379: Python @NCKU CSIE

>>> >>> for i in range(5):

Addition for Loopbreak exit from loop

Page 380: Python @NCKU CSIE

>>> >>> for i in range(5):>>> for i in range(5):...

Addition for Loopbreak exit from loop

Page 381: Python @NCKU CSIE

>>> >>> for i in range(5):>>> for i in range(5):...>>> for i in range(5):... if i == 2:

Addition for Loopbreak exit from loop

Page 382: Python @NCKU CSIE

>>> >>> for i in range(5):>>> for i in range(5):...>>> for i in range(5):... if i == 2:>>> for i in range(5):... if i == 2:...

Addition for Loopbreak exit from loop

Page 383: Python @NCKU CSIE

>>> >>> for i in range(5):>>> for i in range(5):...>>> for i in range(5):... if i == 2:>>> for i in range(5):... if i == 2:...

>>> for i in range(5):... if i == 2:... break

Addition for Loopbreak exit from loop

Page 384: Python @NCKU CSIE

>>> >>> for i in range(5):>>> for i in range(5):...>>> for i in range(5):... if i == 2:>>> for i in range(5):... if i == 2:...

>>> for i in range(5):... if i == 2:... break

>>> for i in range(5):... if i == 2:... break...

Addition for Loopbreak exit from loop

Page 385: Python @NCKU CSIE

>>> >>> for i in range(5):>>> for i in range(5):...>>> for i in range(5):... if i == 2:>>> for i in range(5):... if i == 2:...

>>> for i in range(5):... if i == 2:... break

>>> for i in range(5):... if i == 2:... break...

>>> for i in range(5):... if i == 2:... break... print i

Addition for Loopbreak exit from loop

Page 386: Python @NCKU CSIE

>>> >>> for i in range(5):>>> for i in range(5):...>>> for i in range(5):... if i == 2:>>> for i in range(5):... if i == 2:...

>>> for i in range(5):... if i == 2:... break

>>> for i in range(5):... if i == 2:... break...

>>> for i in range(5):... if i == 2:... break... print i

>>> for i in range(5):... if i == 2:... break... print i...

Addition for Loopbreak exit from loop

Page 387: Python @NCKU CSIE

>>> >>> for i in range(5):>>> for i in range(5):...>>> for i in range(5):... if i == 2:>>> for i in range(5):... if i == 2:...

>>> for i in range(5):... if i == 2:... break

>>> for i in range(5):... if i == 2:... break...

>>> for i in range(5):... if i == 2:... break... print i

>>> for i in range(5):... if i == 2:... break... print i...

>>> for i in range(5):... if i == 2:... break... print i... 01>>>

Addition for Loopbreak exit from loop

Page 388: Python @NCKU CSIE

>>>

Addition for Loopelse do something after unbroken

loop

Page 389: Python @NCKU CSIE

>>>>>> for i in range(3):

Addition for Loopelse do something after unbroken

loop

Page 390: Python @NCKU CSIE

>>>>>> for i in range(3):>>> for i in range(3):...

Addition for Loopelse do something after unbroken

loop

Page 391: Python @NCKU CSIE

>>>>>> for i in range(3):>>> for i in range(3):...>>> for i in range(3):... print i

Addition for Loopelse do something after unbroken

loop

Page 392: Python @NCKU CSIE

>>>>>> for i in range(3):>>> for i in range(3):...>>> for i in range(3):... print i>>> for i in range(3):... print i...

Addition for Loopelse do something after unbroken

loop

Page 393: Python @NCKU CSIE

>>>>>> for i in range(3):>>> for i in range(3):...>>> for i in range(3):... print i>>> for i in range(3):... print i...

>>> for i in range(3):... print i... else:

Addition for Loopelse do something after unbroken

loop

Page 394: Python @NCKU CSIE

>>>>>> for i in range(3):>>> for i in range(3):...>>> for i in range(3):... print i>>> for i in range(3):... print i...

>>> for i in range(3):... print i... else:

>>> for i in range(3):... print i... else:...

Addition for Loopelse do something after unbroken

loop

Page 395: Python @NCKU CSIE

>>>>>> for i in range(3):>>> for i in range(3):...>>> for i in range(3):... print i>>> for i in range(3):... print i...

>>> for i in range(3):... print i... else:

>>> for i in range(3):... print i... else:...

>>> for i in range(3):... print i... else:... print “done”

Addition for Loopelse do something after unbroken

loop

Page 396: Python @NCKU CSIE

>>>>>> for i in range(3):>>> for i in range(3):...>>> for i in range(3):... print i>>> for i in range(3):... print i...

>>> for i in range(3):... print i... else:

>>> for i in range(3):... print i... else:...

>>> for i in range(3):... print i... else:... print “done”

>>> for i in range(3):... print i... else:... print “done”...

Addition for Loopelse do something after unbroken

loop

Page 397: Python @NCKU CSIE

>>>>>> for i in range(3):>>> for i in range(3):...>>> for i in range(3):... print i>>> for i in range(3):... print i...

>>> for i in range(3):... print i... else:

>>> for i in range(3):... print i... else:...

>>> for i in range(3):... print i... else:... print “done”

>>> for i in range(3):... print i... else:... print “done”...

... print i

... else:

... print “done”

...012done>>>

Addition for Loopelse do something after unbroken

loop

Page 398: Python @NCKU CSIE

Standard I/O

Page 399: Python @NCKU CSIE

Evaluated Inputinput read a string can be evaluated

return an evaluated object

>>>

Page 400: Python @NCKU CSIE

Evaluated Inputinput read a string can be evaluated

return an evaluated object

>>> >>> input()

Page 401: Python @NCKU CSIE

Evaluated Inputinput read a string can be evaluated

return an evaluated object

>>> >>> input()>>> input()1

Page 402: Python @NCKU CSIE

Evaluated Inputinput read a string can be evaluated

return an evaluated object

>>> >>> input()>>> input()1>>> input()11>>>

Page 403: Python @NCKU CSIE

Evaluated Inputinput read a string can be evaluated

return an evaluated object

>>> >>> input()>>> input()1>>> input()11>>>

>>> input()11>>> input()

Page 404: Python @NCKU CSIE

Evaluated Inputinput read a string can be evaluated

return an evaluated object

>>> >>> input()>>> input()1>>> input()11>>>

>>> input()11>>> input()

>>> input()11>>> input()1 + 2

Page 405: Python @NCKU CSIE

Evaluated Inputinput read a string can be evaluated

return an evaluated object

>>> >>> input()>>> input()1>>> input()11>>>

>>> input()11>>> input()

>>> input()11>>> input()1 + 2

>>> input()11>>> input()1 + 23>>>

Page 406: Python @NCKU CSIE

Evaluated Inputinput read a string can be evaluated

return an evaluated object

>>> >>> input()>>> input()1>>> input()11>>>

>>> input()11>>> input()

>>> input()11>>> input()1 + 2

>>> input()11>>> input()1 + 23>>>

>>> input()11>>> input()1 + 23>>> input()

Page 407: Python @NCKU CSIE

Evaluated Inputinput read a string can be evaluated

return an evaluated object

>>> >>> input()>>> input()1>>> input()11>>>

>>> input()11>>> input()

>>> input()11>>> input()1 + 2

>>> input()11>>> input()1 + 23>>>

>>> input()11>>> input()1 + 23>>> input()

>>> input()11>>> input()1 + 23>>> input()5.0 / 2

Page 408: Python @NCKU CSIE

Evaluated Inputinput read a string can be evaluated

return an evaluated object

>>> >>> input()>>> input()1>>> input()11>>>

>>> input()11>>> input()

>>> input()11>>> input()1 + 2

>>> input()11>>> input()1 + 23>>>

>>> input()11>>> input()1 + 23>>> input()

>>> input()11>>> input()1 + 23>>> input()5.0 / 2

11>>> input()1 + 23>>> input()5.0 / 22.5>>>

Page 409: Python @NCKU CSIE

Evaluated Inputinput read a string can be evaluated

return an evaluated object

>>> >>> input()>>> input()1>>> input()11>>>

>>> input()11>>> input()

>>> input()11>>> input()1 + 2

>>> input()11>>> input()1 + 23>>>

>>> input()11>>> input()1 + 23>>> input()

>>> input()11>>> input()1 + 23>>> input()5.0 / 2

11>>> input()1 + 23>>> input()5.0 / 22.5>>>

11>>> input()1 + 23>>> input()5.0 / 22.5>>> input()

1>>> input()1 + 23>>> input()5.0 / 22.5>>> input()

Page 410: Python @NCKU CSIE

Evaluated Inputinput read a string can be evaluated

return an evaluated object

>>> >>> input()>>> input()1>>> input()11>>>

>>> input()11>>> input()

>>> input()11>>> input()1 + 2

>>> input()11>>> input()1 + 23>>>

>>> input()11>>> input()1 + 23>>> input()

>>> input()11>>> input()1 + 23>>> input()5.0 / 2

11>>> input()1 + 23>>> input()5.0 / 22.5>>>

11>>> input()1 + 23>>> input()5.0 / 22.5>>> input()

1>>> input()1 + 23>>> input()5.0 / 22.5>>> input()

1>>> input()1 + 23>>> input()5.0 / 22.5>>> input()“aaa bbb”

Page 411: Python @NCKU CSIE

Evaluated Inputinput read a string can be evaluated

return an evaluated object

>>> >>> input()>>> input()1>>> input()11>>>

>>> input()11>>> input()

>>> input()11>>> input()1 + 2

>>> input()11>>> input()1 + 23>>>

>>> input()11>>> input()1 + 23>>> input()

>>> input()11>>> input()1 + 23>>> input()5.0 / 2

11>>> input()1 + 23>>> input()5.0 / 22.5>>>

11>>> input()1 + 23>>> input()5.0 / 22.5>>> input()

1>>> input()1 + 23>>> input()5.0 / 22.5>>> input()

1>>> input()1 + 23>>> input()5.0 / 22.5>>> input()“aaa bbb”

1 + 23>>> input()5.0 / 22.5>>> input()“aaa bbb”‘aaa bbb’>>>

Page 412: Python @NCKU CSIE

Evaluated Inputinput read a string can be evaluated

return an evaluated object

>>> >>> input()>>> input()1>>> input()11>>>

>>> input()11>>> input()

>>> input()11>>> input()1 + 2

>>> input()11>>> input()1 + 23>>>

>>> input()11>>> input()1 + 23>>> input()

>>> input()11>>> input()1 + 23>>> input()5.0 / 2

11>>> input()1 + 23>>> input()5.0 / 22.5>>>

11>>> input()1 + 23>>> input()5.0 / 22.5>>> input()

1>>> input()1 + 23>>> input()5.0 / 22.5>>> input()

1>>> input()1 + 23>>> input()5.0 / 22.5>>> input()“aaa bbb”

1 + 23>>> input()5.0 / 22.5>>> input()“aaa bbb”‘aaa bbb’>>>

1 + 23>>> input()5.0 / 22.5>>> input()“aaa bbb”‘aaa bbb’>>> input()

Page 413: Python @NCKU CSIE

Evaluated Inputinput read a string can be evaluated

return an evaluated object

>>> >>> input()>>> input()1>>> input()11>>>

>>> input()11>>> input()

>>> input()11>>> input()1 + 2

>>> input()11>>> input()1 + 23>>>

>>> input()11>>> input()1 + 23>>> input()

>>> input()11>>> input()1 + 23>>> input()5.0 / 2

11>>> input()1 + 23>>> input()5.0 / 22.5>>>

11>>> input()1 + 23>>> input()5.0 / 22.5>>> input()

1>>> input()1 + 23>>> input()5.0 / 22.5>>> input()

1>>> input()1 + 23>>> input()5.0 / 22.5>>> input()“aaa bbb”

1 + 23>>> input()5.0 / 22.5>>> input()“aaa bbb”‘aaa bbb’>>>

1 + 23>>> input()5.0 / 22.5>>> input()“aaa bbb”‘aaa bbb’>>> input()

3>>> input()5.0 / 22.5>>> input()“aaa bbb”‘aaa bbb’>>> input()

3>>> input()5.0 / 22.5>>> input()“aaa bbb”‘aaa bbb’>>> input()[1, 2, 3]

Page 414: Python @NCKU CSIE

Evaluated Inputinput read a string can be evaluated

return an evaluated object

>>> >>> input()>>> input()1>>> input()11>>>

>>> input()11>>> input()

>>> input()11>>> input()1 + 2

>>> input()11>>> input()1 + 23>>>

>>> input()11>>> input()1 + 23>>> input()

>>> input()11>>> input()1 + 23>>> input()5.0 / 2

11>>> input()1 + 23>>> input()5.0 / 22.5>>>

11>>> input()1 + 23>>> input()5.0 / 22.5>>> input()

1>>> input()1 + 23>>> input()5.0 / 22.5>>> input()

1>>> input()1 + 23>>> input()5.0 / 22.5>>> input()“aaa bbb”

1 + 23>>> input()5.0 / 22.5>>> input()“aaa bbb”‘aaa bbb’>>>

1 + 23>>> input()5.0 / 22.5>>> input()“aaa bbb”‘aaa bbb’>>> input()

3>>> input()5.0 / 22.5>>> input()“aaa bbb”‘aaa bbb’>>> input()

3>>> input()5.0 / 22.5>>> input()“aaa bbb”‘aaa bbb’>>> input()[1, 2, 3]

5.0 / 22.5>>> input()“aaa bbb”‘aaa bbb’>>> input()[1, 2, 3][1, 2, 3]>>>

Page 415: Python @NCKU CSIE

Evaluated Inputinput read a string can be evaluated

return an evaluated object

>>> >>> input()>>> input()1>>> input()11>>>

>>> input()11>>> input()

>>> input()11>>> input()1 + 2

>>> input()11>>> input()1 + 23>>>

>>> input()11>>> input()1 + 23>>> input()

>>> input()11>>> input()1 + 23>>> input()5.0 / 2

11>>> input()1 + 23>>> input()5.0 / 22.5>>>

11>>> input()1 + 23>>> input()5.0 / 22.5>>> input()

1>>> input()1 + 23>>> input()5.0 / 22.5>>> input()

1>>> input()1 + 23>>> input()5.0 / 22.5>>> input()“aaa bbb”

1 + 23>>> input()5.0 / 22.5>>> input()“aaa bbb”‘aaa bbb’>>>

1 + 23>>> input()5.0 / 22.5>>> input()“aaa bbb”‘aaa bbb’>>> input()

3>>> input()5.0 / 22.5>>> input()“aaa bbb”‘aaa bbb’>>> input()

3>>> input()5.0 / 22.5>>> input()“aaa bbb”‘aaa bbb’>>> input()[1, 2, 3]

5.0 / 22.5>>> input()“aaa bbb”‘aaa bbb’>>> input()[1, 2, 3][1, 2, 3]>>>

5.0 / 22.5>>> input()“aaa bbb”‘aaa bbb’>>> input()[1, 2, 3][1, 2, 3]>>> input()

Page 416: Python @NCKU CSIE

Evaluated Inputinput read a string can be evaluated

return an evaluated object

>>> >>> input()>>> input()1>>> input()11>>>

>>> input()11>>> input()

>>> input()11>>> input()1 + 2

>>> input()11>>> input()1 + 23>>>

>>> input()11>>> input()1 + 23>>> input()

>>> input()11>>> input()1 + 23>>> input()5.0 / 2

11>>> input()1 + 23>>> input()5.0 / 22.5>>>

11>>> input()1 + 23>>> input()5.0 / 22.5>>> input()

1>>> input()1 + 23>>> input()5.0 / 22.5>>> input()

1>>> input()1 + 23>>> input()5.0 / 22.5>>> input()“aaa bbb”

1 + 23>>> input()5.0 / 22.5>>> input()“aaa bbb”‘aaa bbb’>>>

1 + 23>>> input()5.0 / 22.5>>> input()“aaa bbb”‘aaa bbb’>>> input()

3>>> input()5.0 / 22.5>>> input()“aaa bbb”‘aaa bbb’>>> input()

3>>> input()5.0 / 22.5>>> input()“aaa bbb”‘aaa bbb’>>> input()[1, 2, 3]

5.0 / 22.5>>> input()“aaa bbb”‘aaa bbb’>>> input()[1, 2, 3][1, 2, 3]>>>

5.0 / 22.5>>> input()“aaa bbb”‘aaa bbb’>>> input()[1, 2, 3][1, 2, 3]>>> input()

2.5>>> input()“aaa bbb”‘aaa bbb’>>> input()[1, 2, 3][1, 2, 3]>>> input()

2.5>>> input()“aaa bbb”‘aaa bbb’>>> input()[1, 2, 3][1, 2, 3]>>> input()1 2

Page 417: Python @NCKU CSIE

Evaluated Inputinput read a string can be evaluated

return an evaluated object

>>> >>> input()>>> input()1>>> input()11>>>

>>> input()11>>> input()

>>> input()11>>> input()1 + 2

>>> input()11>>> input()1 + 23>>>

>>> input()11>>> input()1 + 23>>> input()

>>> input()11>>> input()1 + 23>>> input()5.0 / 2

11>>> input()1 + 23>>> input()5.0 / 22.5>>>

11>>> input()1 + 23>>> input()5.0 / 22.5>>> input()

1>>> input()1 + 23>>> input()5.0 / 22.5>>> input()

1>>> input()1 + 23>>> input()5.0 / 22.5>>> input()“aaa bbb”

1 + 23>>> input()5.0 / 22.5>>> input()“aaa bbb”‘aaa bbb’>>>

1 + 23>>> input()5.0 / 22.5>>> input()“aaa bbb”‘aaa bbb’>>> input()

3>>> input()5.0 / 22.5>>> input()“aaa bbb”‘aaa bbb’>>> input()

3>>> input()5.0 / 22.5>>> input()“aaa bbb”‘aaa bbb’>>> input()[1, 2, 3]

5.0 / 22.5>>> input()“aaa bbb”‘aaa bbb’>>> input()[1, 2, 3][1, 2, 3]>>>

5.0 / 22.5>>> input()“aaa bbb”‘aaa bbb’>>> input()[1, 2, 3][1, 2, 3]>>> input()

2.5>>> input()“aaa bbb”‘aaa bbb’>>> input()[1, 2, 3][1, 2, 3]>>> input()

2.5>>> input()“aaa bbb”‘aaa bbb’>>> input()[1, 2, 3][1, 2, 3]>>> input()1 2

>>> input()1 2Traceback (most recent call last): File "<input>", line 1, in <module> File "<string>", line 1 1 2 ^SyntaxError: unexpected EOF while parsing>>>

Page 418: Python @NCKU CSIE

>>>

Raw Inputraw_input() read a string

return a string

Page 419: Python @NCKU CSIE

>>> >>> raw_input()

Raw Inputraw_input() read a string

return a string

Page 420: Python @NCKU CSIE

>>> >>> raw_input()>>> raw_input()1

Raw Inputraw_input() read a string

return a string

Page 421: Python @NCKU CSIE

>>> >>> raw_input()>>> raw_input()1>>> raw_input()1‘1’>>>

Raw Inputraw_input() read a string

return a string

Page 422: Python @NCKU CSIE

>>> >>> raw_input()>>> raw_input()1>>> raw_input()1‘1’>>>

>>> raw_input()1‘1’>>> raw_input()

Raw Inputraw_input() read a string

return a string

Page 423: Python @NCKU CSIE

>>> >>> raw_input()>>> raw_input()1>>> raw_input()1‘1’>>>

>>> raw_input()1‘1’>>> raw_input()

>>> raw_input()1‘1’>>> raw_input()1 + 2

Raw Inputraw_input() read a string

return a string

Page 424: Python @NCKU CSIE

>>> >>> raw_input()>>> raw_input()1>>> raw_input()1‘1’>>>

>>> raw_input()1‘1’>>> raw_input()

>>> raw_input()1‘1’>>> raw_input()1 + 2

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>>

Raw Inputraw_input() read a string

return a string

Page 425: Python @NCKU CSIE

>>> >>> raw_input()>>> raw_input()1>>> raw_input()1‘1’>>>

>>> raw_input()1‘1’>>> raw_input()

>>> raw_input()1‘1’>>> raw_input()1 + 2

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>>

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()

Raw Inputraw_input() read a string

return a string

Page 426: Python @NCKU CSIE

>>> >>> raw_input()>>> raw_input()1>>> raw_input()1‘1’>>>

>>> raw_input()1‘1’>>> raw_input()

>>> raw_input()1‘1’>>> raw_input()1 + 2

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>>

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2

Raw Inputraw_input() read a string

return a string

Page 427: Python @NCKU CSIE

>>> >>> raw_input()>>> raw_input()1>>> raw_input()1‘1’>>>

>>> raw_input()1‘1’>>> raw_input()

>>> raw_input()1‘1’>>> raw_input()1 + 2

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>>

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2

1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>>

Raw Inputraw_input() read a string

return a string

Page 428: Python @NCKU CSIE

>>> >>> raw_input()>>> raw_input()1>>> raw_input()1‘1’>>>

>>> raw_input()1‘1’>>> raw_input()

>>> raw_input()1‘1’>>> raw_input()1 + 2

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>>

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2

1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>>

1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()

‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()

Raw Inputraw_input() read a string

return a string

Page 429: Python @NCKU CSIE

>>> >>> raw_input()>>> raw_input()1>>> raw_input()1‘1’>>>

>>> raw_input()1‘1’>>> raw_input()

>>> raw_input()1‘1’>>> raw_input()1 + 2

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>>

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2

1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>>

1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()

‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()

‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”

Raw Inputraw_input() read a string

return a string

Page 430: Python @NCKU CSIE

>>> >>> raw_input()>>> raw_input()1>>> raw_input()1‘1’>>>

>>> raw_input()1‘1’>>> raw_input()

>>> raw_input()1‘1’>>> raw_input()1 + 2

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>>

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2

1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>>

1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()

‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()

‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”

1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>>

Raw Inputraw_input() read a string

return a string

Page 431: Python @NCKU CSIE

>>> >>> raw_input()>>> raw_input()1>>> raw_input()1‘1’>>>

>>> raw_input()1‘1’>>> raw_input()

>>> raw_input()1‘1’>>> raw_input()1 + 2

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>>

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2

1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>>

1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()

‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()

‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”

1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>>

1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>> raw_input()

Raw Inputraw_input() read a string

return a string

Page 432: Python @NCKU CSIE

>>> >>> raw_input()>>> raw_input()1>>> raw_input()1‘1’>>>

>>> raw_input()1‘1’>>> raw_input()

>>> raw_input()1‘1’>>> raw_input()1 + 2

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>>

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2

1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>>

1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()

‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()

‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”

1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>>

1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>> raw_input()

‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>> raw_input()

‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>> raw_input()[1, 2, 3]

Raw Inputraw_input() read a string

return a string

Page 433: Python @NCKU CSIE

>>> >>> raw_input()>>> raw_input()1>>> raw_input()1‘1’>>>

>>> raw_input()1‘1’>>> raw_input()

>>> raw_input()1‘1’>>> raw_input()1 + 2

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>>

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2

1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>>

1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()

‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()

‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”

1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>>

1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>> raw_input()

‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>> raw_input()

‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>> raw_input()[1, 2, 3]

5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>> raw_input()[1, 2, 3]‘[1, 2, 3]’>>>

Raw Inputraw_input() read a string

return a string

Page 434: Python @NCKU CSIE

>>> >>> raw_input()>>> raw_input()1>>> raw_input()1‘1’>>>

>>> raw_input()1‘1’>>> raw_input()

>>> raw_input()1‘1’>>> raw_input()1 + 2

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>>

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2

1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>>

1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()

‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()

‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”

1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>>

1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>> raw_input()

‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>> raw_input()

‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>> raw_input()[1, 2, 3]

5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>> raw_input()[1, 2, 3]‘[1, 2, 3]’>>>

5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>> raw_input()[1, 2, 3]‘[1, 2, 3]’>>> raw_input()

Raw Inputraw_input() read a string

return a string

Page 435: Python @NCKU CSIE

>>> >>> raw_input()>>> raw_input()1>>> raw_input()1‘1’>>>

>>> raw_input()1‘1’>>> raw_input()

>>> raw_input()1‘1’>>> raw_input()1 + 2

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>>

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2

1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>>

1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()

‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()

‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”

1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>>

1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>> raw_input()

‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>> raw_input()

‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>> raw_input()[1, 2, 3]

5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>> raw_input()[1, 2, 3]‘[1, 2, 3]’>>>

5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>> raw_input()[1, 2, 3]‘[1, 2, 3]’>>> raw_input()

‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>> raw_input()[1, 2, 3]‘[1, 2, 3]’>>> raw_input()

‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>> raw_input()[1, 2, 3]‘[1, 2, 3]’>>> raw_input()1 2

Raw Inputraw_input() read a string

return a string

Page 436: Python @NCKU CSIE

>>> >>> raw_input()>>> raw_input()1>>> raw_input()1‘1’>>>

>>> raw_input()1‘1’>>> raw_input()

>>> raw_input()1‘1’>>> raw_input()1 + 2

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>>

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()

>>> raw_input()1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2

1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>>

1‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()

‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()

‘1’>>> raw_input()1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”

1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>>

1 + 2‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>> raw_input()

‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>> raw_input()

‘1 + 2’>>> raw_input()5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>> raw_input()[1, 2, 3]

5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>> raw_input()[1, 2, 3]‘[1, 2, 3]’>>>

5.0 / 2‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>> raw_input()[1, 2, 3]‘[1, 2, 3]’>>> raw_input()

‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>> raw_input()[1, 2, 3]‘[1, 2, 3]’>>> raw_input()

‘5.0 / 2’>>> raw_input()“aaa bbb”‘“aaa bbb”’>>> raw_input()[1, 2, 3]‘[1, 2, 3]’>>> raw_input()1 2

“aaa bbb”‘“aaa bbb”’>>> raw_input()[1, 2, 3]‘[1, 2, 3]’>>> raw_input()1 2‘1 2’>>>

Raw Inputraw_input() read a string

return a string

Page 437: Python @NCKU CSIE

Outputprint print object to standard output

>>>

Page 438: Python @NCKU CSIE

Outputprint print object to standard output

>>>>>> print “Hello World!”

Page 439: Python @NCKU CSIE

Outputprint print object to standard output

>>>>>> print “Hello World!”>>> print “Hello World!”Hello World!>>>

Page 440: Python @NCKU CSIE

Outputprint print object to standard output

>>>>>> print “Hello World!”>>> print “Hello World!”Hello World!>>>

>>> print “Hello World!”Hello World!>>> print “Hello”, “World!”

Page 441: Python @NCKU CSIE

Outputprint print object to standard output

>>>>>> print “Hello World!”>>> print “Hello World!”Hello World!>>>

>>> print “Hello World!”Hello World!>>> print “Hello”, “World!”

>>> print “Hello World!”Hello World!>>> print “Hello”, “World!”Hello World!>>>

Page 442: Python @NCKU CSIE

Outputprint print object to standard output

>>>>>> print “Hello World!”>>> print “Hello World!”Hello World!>>>

>>> print “Hello World!”Hello World!>>> print “Hello”, “World!”

>>> print “Hello World!”Hello World!>>> print “Hello”, “World!”Hello World!>>>

>>> print “Hello World!”Hello World!>>> print “Hello”, “World!”Hello World!>>> print 1 + 2

Page 443: Python @NCKU CSIE

Outputprint print object to standard output

>>>>>> print “Hello World!”>>> print “Hello World!”Hello World!>>>

>>> print “Hello World!”Hello World!>>> print “Hello”, “World!”

>>> print “Hello World!”Hello World!>>> print “Hello”, “World!”Hello World!>>>

>>> print “Hello World!”Hello World!>>> print “Hello”, “World!”Hello World!>>> print 1 + 2

>>> print “Hello World!”Hello World!>>> print “Hello”, “World!”Hello World!>>> print 1 + 23>>>

Page 444: Python @NCKU CSIE

Outputprint print object to standard output

>>>>>> print “Hello World!”>>> print “Hello World!”Hello World!>>>

>>> print “Hello World!”Hello World!>>> print “Hello”, “World!”

>>> print “Hello World!”Hello World!>>> print “Hello”, “World!”Hello World!>>>

>>> print “Hello World!”Hello World!>>> print “Hello”, “World!”Hello World!>>> print 1 + 2

>>> print “Hello World!”Hello World!>>> print “Hello”, “World!”Hello World!>>> print 1 + 23>>>

>>> print “Hello World!”Hello World!>>> print “Hello”, “World!”Hello World!>>> print 1 + 23>>> print [1, 2, 3]

Page 445: Python @NCKU CSIE

Outputprint print object to standard output

>>>>>> print “Hello World!”>>> print “Hello World!”Hello World!>>>

>>> print “Hello World!”Hello World!>>> print “Hello”, “World!”

>>> print “Hello World!”Hello World!>>> print “Hello”, “World!”Hello World!>>>

>>> print “Hello World!”Hello World!>>> print “Hello”, “World!”Hello World!>>> print 1 + 2

>>> print “Hello World!”Hello World!>>> print “Hello”, “World!”Hello World!>>> print 1 + 23>>>

>>> print “Hello World!”Hello World!>>> print “Hello”, “World!”Hello World!>>> print 1 + 23>>> print [1, 2, 3]

>>> print “Hello World!”Hello World!>>> print “Hello”, “World!”Hello World!>>> print 1 + 23>>> print [1, 2, 3][1, 2, 3]>>>

Page 446: Python @NCKU CSIE

Custom Function

Page 447: Python @NCKU CSIE

>>>

Define a Function

Page 448: Python @NCKU CSIE

>>>>>> def SQ(x):

Define a Function

Page 449: Python @NCKU CSIE

>>>>>> def SQ(x):>>> def SQ(x):...

Define a Function

Page 450: Python @NCKU CSIE

>>>>>> def SQ(x):>>> def SQ(x):...>>> def SQ(x):... return x * x

Define a Function

Page 451: Python @NCKU CSIE

>>>>>> def SQ(x):>>> def SQ(x):...>>> def SQ(x):... return x * x>>> def SQ(x):... return x * x...

Define a Function

Page 452: Python @NCKU CSIE

>>>>>> def SQ(x):>>> def SQ(x):...>>> def SQ(x):... return x * x>>> def SQ(x):... return x * x...

>>> def SQ(x):... return x * x...>>>

Define a Function

Page 453: Python @NCKU CSIE

>>>>>> def SQ(x):>>> def SQ(x):...>>> def SQ(x):... return x * x>>> def SQ(x):... return x * x...

>>> def SQ(x):... return x * x...>>>

>>> def SQ(x):... return x * x...>>> SQ(10)

Define a Function

Page 454: Python @NCKU CSIE

>>>>>> def SQ(x):>>> def SQ(x):...>>> def SQ(x):... return x * x>>> def SQ(x):... return x * x...

>>> def SQ(x):... return x * x...>>>

>>> def SQ(x):... return x * x...>>> SQ(10)

>>> def SQ(x):... return x * x...>>> SQ(10)100>>>

Define a Function

Page 455: Python @NCKU CSIE

>>>>>> def SQ(x):>>> def SQ(x):...>>> def SQ(x):... return x * x>>> def SQ(x):... return x * x...

>>> def SQ(x):... return x * x...>>>

>>> def SQ(x):... return x * x...>>> SQ(10)

>>> def SQ(x):... return x * x...>>> SQ(10)100>>>

Define a Function>>> def SQ(x):... return x * x...>>> SQ(10)100>>>

Page 456: Python @NCKU CSIE

>>>>>> def SQ(x):>>> def SQ(x):...>>> def SQ(x):... return x * x>>> def SQ(x):... return x * x...

>>> def SQ(x):... return x * x...>>>

>>> def SQ(x):... return x * x...>>> SQ(10)

>>> def SQ(x):... return x * x...>>> SQ(10)100>>>

Define a Function>>> def SQ(x):... return x * x...>>> SQ(10)100>>>

function name

Page 457: Python @NCKU CSIE

>>>>>> def SQ(x):>>> def SQ(x):...>>> def SQ(x):... return x * x>>> def SQ(x):... return x * x...

>>> def SQ(x):... return x * x...>>>

>>> def SQ(x):... return x * x...>>> SQ(10)

>>> def SQ(x):... return x * x...>>> SQ(10)100>>>

Define a Function>>> def SQ(x):... return x * x...>>> SQ(10)100>>>

function name

parameter

Page 458: Python @NCKU CSIE

>>>>>> def SQ(x):>>> def SQ(x):...>>> def SQ(x):... return x * x>>> def SQ(x):... return x * x...

>>> def SQ(x):... return x * x...>>>

>>> def SQ(x):... return x * x...>>> SQ(10)

>>> def SQ(x):... return x * x...>>> SQ(10)100>>>

Define a Function>>> def SQ(x):... return x * x...>>> SQ(10)100>>>

function name

parameter

function content

Page 459: Python @NCKU CSIE

Lambda Function>>>

Page 460: Python @NCKU CSIE

Lambda Function>>>>>> CUBE = lambda k: k * k * k

Page 461: Python @NCKU CSIE

Lambda Function>>>>>> CUBE = lambda k: k * k * k>>> CUBE = lambda k: k * k * k>>>

Page 462: Python @NCKU CSIE

Lambda Function>>>>>> CUBE = lambda k: k * k * k>>> CUBE = lambda k: k * k * k>>>>>> CUBE = lambda k: k * k * k>>> CUBE(10)

Page 463: Python @NCKU CSIE

Lambda Function>>>>>> CUBE = lambda k: k * k * k>>> CUBE = lambda k: k * k * k>>>>>> CUBE = lambda k: k * k * k>>> CUBE(10)>>> CUBE = lambda k: k * k * k>>> CUBE(10)1000>>>

Page 464: Python @NCKU CSIE

Lambda Function>>>>>> CUBE = lambda k: k * k * k>>> CUBE = lambda k: k * k * k>>>>>> CUBE = lambda k: k * k * k>>> CUBE(10)>>> CUBE = lambda k: k * k * k>>> CUBE(10)1000>>>

>>> CUBE = lambda k: k * k * k>>> CUBE(10)1000>>> (lambda x, y: x * y)(3, 4)

Page 465: Python @NCKU CSIE

Lambda Function>>>>>> CUBE = lambda k: k * k * k>>> CUBE = lambda k: k * k * k>>>>>> CUBE = lambda k: k * k * k>>> CUBE(10)>>> CUBE = lambda k: k * k * k>>> CUBE(10)1000>>>

>>> CUBE = lambda k: k * k * k>>> CUBE(10)1000>>> (lambda x, y: x * y)(3, 4)

>>> CUBE = lambda k: k * k * k>>> CUBE(10)1000>>> (lambda x, y: x * y)(3, 4)12>>>

Page 466: Python @NCKU CSIE

Lambda Function>>>>>> CUBE = lambda k: k * k * k>>> CUBE = lambda k: k * k * k>>>>>> CUBE = lambda k: k * k * k>>> CUBE(10)>>> CUBE = lambda k: k * k * k>>> CUBE(10)1000>>>

>>> CUBE = lambda k: k * k * k>>> CUBE(10)1000>>> (lambda x, y: x * y)(3, 4)

>>> CUBE = lambda k: k * k * k>>> CUBE(10)1000>>> (lambda x, y: x * y)(3, 4)12>>>

>>> CUBE = lambda k: k * k * k>>> CUBE(10)1000>>> (lambda x, y: x * y)(3, 4)12>>>

Page 467: Python @NCKU CSIE

Lambda Function>>>>>> CUBE = lambda k: k * k * k>>> CUBE = lambda k: k * k * k>>>>>> CUBE = lambda k: k * k * k>>> CUBE(10)>>> CUBE = lambda k: k * k * k>>> CUBE(10)1000>>>

>>> CUBE = lambda k: k * k * k>>> CUBE(10)1000>>> (lambda x, y: x * y)(3, 4)

>>> CUBE = lambda k: k * k * k>>> CUBE(10)1000>>> (lambda x, y: x * y)(3, 4)12>>>

>>> CUBE = lambda k: k * k * k>>> CUBE(10)1000>>> (lambda x, y: x * y)(3, 4)12>>>

parameter

Page 468: Python @NCKU CSIE

Lambda Function>>>>>> CUBE = lambda k: k * k * k>>> CUBE = lambda k: k * k * k>>>>>> CUBE = lambda k: k * k * k>>> CUBE(10)>>> CUBE = lambda k: k * k * k>>> CUBE(10)1000>>>

>>> CUBE = lambda k: k * k * k>>> CUBE(10)1000>>> (lambda x, y: x * y)(3, 4)

>>> CUBE = lambda k: k * k * k>>> CUBE(10)1000>>> (lambda x, y: x * y)(3, 4)12>>>

>>> CUBE = lambda k: k * k * k>>> CUBE(10)1000>>> (lambda x, y: x * y)(3, 4)12>>>

parameterreturn value

Page 469: Python @NCKU CSIE

Built-in Function

Page 470: Python @NCKU CSIE

range>>>

Page 471: Python @NCKU CSIE

range>>>>>> range(10)

Page 472: Python @NCKU CSIE

range>>>>>> range(10)>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>>

Page 473: Python @NCKU CSIE

range>>>>>> range(10)>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>>

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)

Page 474: Python @NCKU CSIE

range>>>>>> range(10)>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>>

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>>

Page 475: Python @NCKU CSIE

range>>>>>> range(10)>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>>

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>>

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>> range(1, 10, 2)

Page 476: Python @NCKU CSIE

range>>>>>> range(10)>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>>

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>>

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>> range(1, 10, 2)

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>> range(1, 10, 2)[1, 3, 5, 7, 9]>>>

Page 477: Python @NCKU CSIE

range>>>>>> range(10)>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>>

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>>

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>> range(1, 10, 2)

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>> range(1, 10, 2)[1, 3, 5, 7, 9]>>>

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>> range(1, 10, 2)[1, 3, 5, 7, 9]>>> range(10, 0, -1)

Page 478: Python @NCKU CSIE

range>>>>>> range(10)>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>>

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>>

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>> range(1, 10, 2)

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>> range(1, 10, 2)[1, 3, 5, 7, 9]>>>

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>> range(1, 10, 2)[1, 3, 5, 7, 9]>>> range(10, 0, -1)

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>> range(1, 10, 2)[1, 3, 5, 7, 9]>>> range(10, 0, -1)[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]>>>

Page 479: Python @NCKU CSIE

range>>>>>> range(10)>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>>

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>>

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>> range(1, 10, 2)

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>> range(1, 10, 2)[1, 3, 5, 7, 9]>>>

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>> range(1, 10, 2)[1, 3, 5, 7, 9]>>> range(10, 0, -1)

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>> range(1, 10, 2)[1, 3, 5, 7, 9]>>> range(10, 0, -1)[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]>>>

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>> range(1, 10, 2)[1, 3, 5, 7, 9]>>> range(10, 0, -1)[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]>>>

Page 480: Python @NCKU CSIE

range>>>>>> range(10)>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>>

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>>

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>> range(1, 10, 2)

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>> range(1, 10, 2)[1, 3, 5, 7, 9]>>>

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>> range(1, 10, 2)[1, 3, 5, 7, 9]>>> range(10, 0, -1)

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>> range(1, 10, 2)[1, 3, 5, 7, 9]>>> range(10, 0, -1)[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]>>>

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>> range(1, 10, 2)[1, 3, 5, 7, 9]>>> range(10, 0, -1)[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]>>>

range(stop)

Page 481: Python @NCKU CSIE

range>>>>>> range(10)>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>>

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>>

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>> range(1, 10, 2)

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>> range(1, 10, 2)[1, 3, 5, 7, 9]>>>

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>> range(1, 10, 2)[1, 3, 5, 7, 9]>>> range(10, 0, -1)

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>> range(1, 10, 2)[1, 3, 5, 7, 9]>>> range(10, 0, -1)[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]>>>

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>> range(1, 10, 2)[1, 3, 5, 7, 9]>>> range(10, 0, -1)[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]>>>

range(stop)

range(start, stop)

Page 482: Python @NCKU CSIE

range>>>>>> range(10)>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>>

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>>

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>> range(1, 10, 2)

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>> range(1, 10, 2)[1, 3, 5, 7, 9]>>>

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>> range(1, 10, 2)[1, 3, 5, 7, 9]>>> range(10, 0, -1)

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>> range(1, 10, 2)[1, 3, 5, 7, 9]>>> range(10, 0, -1)[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]>>>

>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(3, 10)[3, 4, 5, 6, 7, 8, 9]>>> range(1, 10, 2)[1, 3, 5, 7, 9]>>> range(10, 0, -1)[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]>>>

range(stop)

range(start, stop)

range(start, stop, step)

Page 483: Python @NCKU CSIE

>>>

filter

Page 484: Python @NCKU CSIE

>>>>>> x = range(1, 11)

filter

Page 485: Python @NCKU CSIE

>>>>>> x = range(1, 11)>>> x = range(1, 11)>>>

filter

Page 486: Python @NCKU CSIE

>>>>>> x = range(1, 11)>>> x = range(1, 11)>>>>>> x = range(1, 11)>>> filter(lambda k: k % 2 == 0, x)

filter

Page 487: Python @NCKU CSIE

>>>>>> x = range(1, 11)>>> x = range(1, 11)>>>>>> x = range(1, 11)>>> filter(lambda k: k % 2 == 0, x)>>> x = range(1, 11)>>> filter(lambda k: k % 2 == 0, x)[2, 4, 6, 8, 10]>>>

filter

Page 488: Python @NCKU CSIE

>>>>>> x = range(1, 11)>>> x = range(1, 11)>>>>>> x = range(1, 11)>>> filter(lambda k: k % 2 == 0, x)>>> x = range(1, 11)>>> filter(lambda k: k % 2 == 0, x)[2, 4, 6, 8, 10]>>>

>>> x = range(1, 11)>>> filter(lambda k: k % 2 == 0, x)[2, 4, 6, 8, 10]>>>

filter

Page 489: Python @NCKU CSIE

>>>>>> x = range(1, 11)>>> x = range(1, 11)>>>>>> x = range(1, 11)>>> filter(lambda k: k % 2 == 0, x)>>> x = range(1, 11)>>> filter(lambda k: k % 2 == 0, x)[2, 4, 6, 8, 10]>>>

>>> x = range(1, 11)>>> filter(lambda k: k % 2 == 0, x)[2, 4, 6, 8, 10]>>>

filter

a function receive one parameter and return boolean value

Page 490: Python @NCKU CSIE

>>>>>> x = range(1, 11)>>> x = range(1, 11)>>>>>> x = range(1, 11)>>> filter(lambda k: k % 2 == 0, x)>>> x = range(1, 11)>>> filter(lambda k: k % 2 == 0, x)[2, 4, 6, 8, 10]>>>

>>> x = range(1, 11)>>> filter(lambda k: k % 2 == 0, x)[2, 4, 6, 8, 10]>>>

filter

a function receive one parameter and return boolean value

iterable object

Page 491: Python @NCKU CSIE

>>>

map

Page 492: Python @NCKU CSIE

>>>>>> x = range(1, 6)

map

Page 493: Python @NCKU CSIE

>>>>>> x = range(1, 6)>>> x = range(1, 6)>>>

map

Page 494: Python @NCKU CSIE

>>>>>> x = range(1, 6)>>> x = range(1, 6)>>>>>> x = range(1, 6)>>> map(lambda k: k * k, x)

map

Page 495: Python @NCKU CSIE

>>>>>> x = range(1, 6)>>> x = range(1, 6)>>>>>> x = range(1, 6)>>> map(lambda k: k * k, x)>>> x = range(1, 6)>>> map(lambda k: k * k, x)[1, 4, 9, 16, 25]>>>

map

Page 496: Python @NCKU CSIE

>>>>>> x = range(1, 6)>>> x = range(1, 6)>>>>>> x = range(1, 6)>>> map(lambda k: k * k, x)>>> x = range(1, 6)>>> map(lambda k: k * k, x)[1, 4, 9, 16, 25]>>>

>>> x = range(1, 6)>>> map(lambda k: k * k, x)[1, 4, 9, 16, 25]>>>

map

Page 497: Python @NCKU CSIE

>>>>>> x = range(1, 6)>>> x = range(1, 6)>>>>>> x = range(1, 6)>>> map(lambda k: k * k, x)>>> x = range(1, 6)>>> map(lambda k: k * k, x)[1, 4, 9, 16, 25]>>>

>>> x = range(1, 6)>>> map(lambda k: k * k, x)[1, 4, 9, 16, 25]>>>

map

any function receive one parameter

Page 498: Python @NCKU CSIE

>>>>>> x = range(1, 6)>>> x = range(1, 6)>>>>>> x = range(1, 6)>>> map(lambda k: k * k, x)>>> x = range(1, 6)>>> map(lambda k: k * k, x)[1, 4, 9, 16, 25]>>>

>>> x = range(1, 6)>>> map(lambda k: k * k, x)[1, 4, 9, 16, 25]>>>

map

any function receive one parameter

iterable object

Page 499: Python @NCKU CSIE

>>>

reduce

Page 500: Python @NCKU CSIE

>>>>>> x = range(1, 6)

reduce

Page 501: Python @NCKU CSIE

>>>>>> x = range(1, 6)>>> x = range(1, 6)>>>

reduce

Page 502: Python @NCKU CSIE

>>>>>> x = range(1, 6)>>> x = range(1, 6)>>>>>> x = range(1, 6)>>> reduce(lambda a, b: a**2 + b, x)

reduce

Page 503: Python @NCKU CSIE

>>>>>> x = range(1, 6)>>> x = range(1, 6)>>>>>> x = range(1, 6)>>> reduce(lambda a, b: a**2 + b, x)>>> x = range(1, 6)>>> reduce(lambda a, b: a**2 + b, x)21909>>>

reduce

Page 504: Python @NCKU CSIE

>>>>>> x = range(1, 6)>>> x = range(1, 6)>>>>>> x = range(1, 6)>>> reduce(lambda a, b: a**2 + b, x)>>> x = range(1, 6)>>> reduce(lambda a, b: a**2 + b, x)21909>>>

>>> x = range(1, 6)>>> reduce(lambda a, b: a**2 + b, x)21909>>>

reduce

Page 505: Python @NCKU CSIE

>>>>>> x = range(1, 6)>>> x = range(1, 6)>>>>>> x = range(1, 6)>>> reduce(lambda a, b: a**2 + b, x)>>> x = range(1, 6)>>> reduce(lambda a, b: a**2 + b, x)21909>>>

>>> x = range(1, 6)>>> reduce(lambda a, b: a**2 + b, x)21909>>>

reduce

any function receive two parameters

Page 506: Python @NCKU CSIE

>>>>>> x = range(1, 6)>>> x = range(1, 6)>>>>>> x = range(1, 6)>>> reduce(lambda a, b: a**2 + b, x)>>> x = range(1, 6)>>> reduce(lambda a, b: a**2 + b, x)21909>>>

>>> x = range(1, 6)>>> reduce(lambda a, b: a**2 + b, x)21909>>>

reduce

any function receive two parameters

iterable object

Page 507: Python @NCKU CSIE

>>>>>> x = range(1, 6)>>> x = range(1, 6)>>>>>> x = range(1, 6)>>> reduce(lambda a, b: a**2 + b, x)>>> x = range(1, 6)>>> reduce(lambda a, b: a**2 + b, x)21909>>>

>>> x = range(1, 6)>>> reduce(lambda a, b: a**2 + b, x)21909>>>

reduce

any function receive two parameters

iterable object

calculate ((((1^2)+2)^2+3)^2+4)^2+5

Page 508: Python @NCKU CSIE

>>>

factorial

Page 509: Python @NCKU CSIE

>>>>>> reduce(lambda a, b: a * b, range(1, 6))

factorial

Page 510: Python @NCKU CSIE

>>>>>> reduce(lambda a, b: a * b, range(1, 6))>>> reduce(lambda a, b: a * b, range(1, 6))120>>>

factorial

Page 511: Python @NCKU CSIE

Comprehension

Page 512: Python @NCKU CSIE

List Comprehension>>>

Page 513: Python @NCKU CSIE

List Comprehension>>>>>> [i**2 for i in range(1, 6)]

Page 514: Python @NCKU CSIE

List Comprehension>>>>>> [i**2 for i in range(1, 6)]>>> [i**2 for i in range(1, 6)][1, 4, 9, 16, 25]>>>

Page 515: Python @NCKU CSIE

List Comprehension>>>>>> [i**2 for i in range(1, 6)]>>> [i**2 for i in range(1, 6)][1, 4, 9, 16, 25]>>>

>>> [i**2 for i in range(1, 6)][1, 4, 9, 16, 25]>>> [str(i) for i in range(5)]

Page 516: Python @NCKU CSIE

List Comprehension>>>>>> [i**2 for i in range(1, 6)]>>> [i**2 for i in range(1, 6)][1, 4, 9, 16, 25]>>>

>>> [i**2 for i in range(1, 6)][1, 4, 9, 16, 25]>>> [str(i) for i in range(5)]

>>> [i**2 for i in range(1, 6)][1, 4, 9, 16, 25]>>> [str(i) for i in range(5)]['0', '1', '2', '3', '4']>>>

Page 517: Python @NCKU CSIE

List Comprehension>>>>>> [i**2 for i in range(1, 6)]>>> [i**2 for i in range(1, 6)][1, 4, 9, 16, 25]>>>

>>> [i**2 for i in range(1, 6)][1, 4, 9, 16, 25]>>> [str(i) for i in range(5)]

>>> [i**2 for i in range(1, 6)][1, 4, 9, 16, 25]>>> [str(i) for i in range(5)]['0', '1', '2', '3', '4']>>>

>>> [i**2 for i in range(1, 6)][1, 4, 9, 16, 25]>>> [str(i) for i in range(5)]['0', '1', '2', '3', '4']>>>

Page 518: Python @NCKU CSIE

List Comprehension>>>>>> [i**2 for i in range(1, 6)]>>> [i**2 for i in range(1, 6)][1, 4, 9, 16, 25]>>>

>>> [i**2 for i in range(1, 6)][1, 4, 9, 16, 25]>>> [str(i) for i in range(5)]

>>> [i**2 for i in range(1, 6)][1, 4, 9, 16, 25]>>> [str(i) for i in range(5)]['0', '1', '2', '3', '4']>>>

>>> [i**2 for i in range(1, 6)][1, 4, 9, 16, 25]>>> [str(i) for i in range(5)]['0', '1', '2', '3', '4']>>>

processing & return value

Page 519: Python @NCKU CSIE

List Comprehension>>>>>> [i**2 for i in range(1, 6)]>>> [i**2 for i in range(1, 6)][1, 4, 9, 16, 25]>>>

>>> [i**2 for i in range(1, 6)][1, 4, 9, 16, 25]>>> [str(i) for i in range(5)]

>>> [i**2 for i in range(1, 6)][1, 4, 9, 16, 25]>>> [str(i) for i in range(5)]['0', '1', '2', '3', '4']>>>

>>> [i**2 for i in range(1, 6)][1, 4, 9, 16, 25]>>> [str(i) for i in range(5)]['0', '1', '2', '3', '4']>>>

processing & return valueiterable object

Page 520: Python @NCKU CSIE

>>>

Dict Comprehension

Page 521: Python @NCKU CSIE

>>>>>> {i: i**2 for i in range(1, 6)}

Dict Comprehension

Page 522: Python @NCKU CSIE

>>>>>> {i: i**2 for i in range(1, 6)}>>> {i: i**2 for i in range(1, 6)}{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}>>>

Dict Comprehension

Page 523: Python @NCKU CSIE

>>>>>> {i: i**2 for i in range(1, 6)}>>> {i: i**2 for i in range(1, 6)}{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}>>>

>>> {i: i**2 for i in range(1, 6)}{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}>>> {i: str(i) for i in range(5)}

Dict Comprehension

Page 524: Python @NCKU CSIE

>>>>>> {i: i**2 for i in range(1, 6)}>>> {i: i**2 for i in range(1, 6)}{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}>>>

>>> {i: i**2 for i in range(1, 6)}{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}>>> {i: str(i) for i in range(5)}

>>> {i: i**2 for i in range(1, 6)}{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}>>> {i: str(i) for i in range(5)}{0: '0', 1: '1', 2: '2', 3: '3', 4: '4'}>>>

Dict Comprehension

Page 525: Python @NCKU CSIE

>>>>>> {i: i**2 for i in range(1, 6)}>>> {i: i**2 for i in range(1, 6)}{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}>>>

>>> {i: i**2 for i in range(1, 6)}{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}>>> {i: str(i) for i in range(5)}

>>> {i: i**2 for i in range(1, 6)}{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}>>> {i: str(i) for i in range(5)}{0: '0', 1: '1', 2: '2', 3: '3', 4: '4'}>>>

>>> {i: i**2 for i in range(1, 6)}{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}>>> {i: str(i) for i in range(5)}{0: '0', 1: '1', 2: '2', 3: '3', 4: '4'}>>>

Dict Comprehension

Page 526: Python @NCKU CSIE

>>>>>> {i: i**2 for i in range(1, 6)}>>> {i: i**2 for i in range(1, 6)}{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}>>>

>>> {i: i**2 for i in range(1, 6)}{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}>>> {i: str(i) for i in range(5)}

>>> {i: i**2 for i in range(1, 6)}{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}>>> {i: str(i) for i in range(5)}{0: '0', 1: '1', 2: '2', 3: '3', 4: '4'}>>>

>>> {i: i**2 for i in range(1, 6)}{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}>>> {i: str(i) for i in range(5)}{0: '0', 1: '1', 2: '2', 3: '3', 4: '4'}>>>

Dict Comprehension

processing & return value

Page 527: Python @NCKU CSIE

>>>>>> {i: i**2 for i in range(1, 6)}>>> {i: i**2 for i in range(1, 6)}{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}>>>

>>> {i: i**2 for i in range(1, 6)}{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}>>> {i: str(i) for i in range(5)}

>>> {i: i**2 for i in range(1, 6)}{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}>>> {i: str(i) for i in range(5)}{0: '0', 1: '1', 2: '2', 3: '3', 4: '4'}>>>

>>> {i: i**2 for i in range(1, 6)}{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}>>> {i: str(i) for i in range(5)}{0: '0', 1: '1', 2: '2', 3: '3', 4: '4'}>>>

Dict Comprehension

processing & return valueiterable object

Page 528: Python @NCKU CSIE

>>>

Generator Comprehension

Page 529: Python @NCKU CSIE

>>>>>> (i**2 for i in range(1, 6))

Generator Comprehension

Page 530: Python @NCKU CSIE

>>>>>> (i**2 for i in range(1, 6))>>> (i**2 for i in range(1, 6))<generator object <genexpr> at 0x110494690>>>>

Generator Comprehension

Page 531: Python @NCKU CSIE

>>>>>> (i**2 for i in range(1, 6))>>> (i**2 for i in range(1, 6))<generator object <genexpr> at 0x110494690>>>>

>>> (i**2 for i in range(1, 6))<generator object <genexpr> at 0x110494690>>>> (str(i) for i in range(5))

Generator Comprehension

Page 532: Python @NCKU CSIE

>>>>>> (i**2 for i in range(1, 6))>>> (i**2 for i in range(1, 6))<generator object <genexpr> at 0x110494690>>>>

>>> (i**2 for i in range(1, 6))<generator object <genexpr> at 0x110494690>>>> (str(i) for i in range(5))

>>> (i**2 for i in range(1, 6))<generator object <genexpr> at 0x110494690>>>> (str(i) for i in range(5))<generator object <genexpr> at 0x1104946e0>>>>

Generator Comprehension

Page 533: Python @NCKU CSIE

>>>>>> (i**2 for i in range(1, 6))>>> (i**2 for i in range(1, 6))<generator object <genexpr> at 0x110494690>>>>

>>> (i**2 for i in range(1, 6))<generator object <genexpr> at 0x110494690>>>> (str(i) for i in range(5))

>>> (i**2 for i in range(1, 6))<generator object <genexpr> at 0x110494690>>>> (str(i) for i in range(5))<generator object <genexpr> at 0x1104946e0>>>>

>>> (i**2 for i in range(1, 6))<generator object <genexpr> at 0x110494690>>>> (str(i) for i in range(5))<generator object <genexpr> at 0x1104946e0>>>>

Generator Comprehension

Page 534: Python @NCKU CSIE

>>>>>> (i**2 for i in range(1, 6))>>> (i**2 for i in range(1, 6))<generator object <genexpr> at 0x110494690>>>>

>>> (i**2 for i in range(1, 6))<generator object <genexpr> at 0x110494690>>>> (str(i) for i in range(5))

>>> (i**2 for i in range(1, 6))<generator object <genexpr> at 0x110494690>>>> (str(i) for i in range(5))<generator object <genexpr> at 0x1104946e0>>>>

>>> (i**2 for i in range(1, 6))<generator object <genexpr> at 0x110494690>>>> (str(i) for i in range(5))<generator object <genexpr> at 0x1104946e0>>>>

Generator Comprehension

processing & return value

Page 535: Python @NCKU CSIE

>>>>>> (i**2 for i in range(1, 6))>>> (i**2 for i in range(1, 6))<generator object <genexpr> at 0x110494690>>>>

>>> (i**2 for i in range(1, 6))<generator object <genexpr> at 0x110494690>>>> (str(i) for i in range(5))

>>> (i**2 for i in range(1, 6))<generator object <genexpr> at 0x110494690>>>> (str(i) for i in range(5))<generator object <genexpr> at 0x1104946e0>>>>

>>> (i**2 for i in range(1, 6))<generator object <genexpr> at 0x110494690>>>> (str(i) for i in range(5))<generator object <genexpr> at 0x1104946e0>>>>

Generator Comprehension

processing & return valueiterable object

Page 536: Python @NCKU CSIE

>>>>>> (i**2 for i in range(1, 6))>>> (i**2 for i in range(1, 6))<generator object <genexpr> at 0x110494690>>>>

>>> (i**2 for i in range(1, 6))<generator object <genexpr> at 0x110494690>>>> (str(i) for i in range(5))

>>> (i**2 for i in range(1, 6))<generator object <genexpr> at 0x110494690>>>> (str(i) for i in range(5))<generator object <genexpr> at 0x1104946e0>>>>

>>> (i**2 for i in range(1, 6))<generator object <genexpr> at 0x110494690>>>> (str(i) for i in range(5))<generator object <genexpr> at 0x1104946e0>>>>

Generator Comprehension

processing & return valueiterable object

it contains the rule in the object

Page 537: Python @NCKU CSIE

>>>>>> (i**2 for i in range(1, 6))>>> (i**2 for i in range(1, 6))<generator object <genexpr> at 0x110494690>>>>

>>> (i**2 for i in range(1, 6))<generator object <genexpr> at 0x110494690>>>> (str(i) for i in range(5))

>>> (i**2 for i in range(1, 6))<generator object <genexpr> at 0x110494690>>>> (str(i) for i in range(5))<generator object <genexpr> at 0x1104946e0>>>>

>>> (i**2 for i in range(1, 6))<generator object <genexpr> at 0x110494690>>>> (str(i) for i in range(5))<generator object <genexpr> at 0x1104946e0>>>>

Generator Comprehension

processing & return valueiterable object

it contains the rule in the objectsave the memory

Page 538: Python @NCKU CSIE

Use a Generator>>>

Page 539: Python @NCKU CSIE

Use a Generator>>>>>> x = (i**2 for i in range(5))

Page 540: Python @NCKU CSIE

Use a Generator>>>>>> x = (i**2 for i in range(5))>>> x = (i**2 for i in range(5))>>>

Page 541: Python @NCKU CSIE

Use a Generator>>>>>> x = (i**2 for i in range(5))>>> x = (i**2 for i in range(5))>>>>>> x = (i**2 for i in range(5))>>> x

Page 542: Python @NCKU CSIE

Use a Generator>>>>>> x = (i**2 for i in range(5))>>> x = (i**2 for i in range(5))>>>>>> x = (i**2 for i in range(5))>>> x>>> x = (i**2 for i in range(5))>>> x<generator object <genexpr> at 0x110494690>>>>

Page 543: Python @NCKU CSIE

Use a Generator>>>>>> x = (i**2 for i in range(5))>>> x = (i**2 for i in range(5))>>>>>> x = (i**2 for i in range(5))>>> x>>> x = (i**2 for i in range(5))>>> x<generator object <genexpr> at 0x110494690>>>>

>>> x = (i**2 for i in range(5))>>> x<generator object <genexpr> at 0x110494690>>>> for i in x:

Page 544: Python @NCKU CSIE

Use a Generator>>>>>> x = (i**2 for i in range(5))>>> x = (i**2 for i in range(5))>>>>>> x = (i**2 for i in range(5))>>> x>>> x = (i**2 for i in range(5))>>> x<generator object <genexpr> at 0x110494690>>>>

>>> x = (i**2 for i in range(5))>>> x<generator object <genexpr> at 0x110494690>>>> for i in x:

>>> x = (i**2 for i in range(5))>>> x<generator object <genexpr> at 0x110494690>>>> for i in x:...

Page 545: Python @NCKU CSIE

Use a Generator>>>>>> x = (i**2 for i in range(5))>>> x = (i**2 for i in range(5))>>>>>> x = (i**2 for i in range(5))>>> x>>> x = (i**2 for i in range(5))>>> x<generator object <genexpr> at 0x110494690>>>>

>>> x = (i**2 for i in range(5))>>> x<generator object <genexpr> at 0x110494690>>>> for i in x:

>>> x = (i**2 for i in range(5))>>> x<generator object <genexpr> at 0x110494690>>>> for i in x:...

>>> x = (i**2 for i in range(5))>>> x<generator object <genexpr> at 0x110494690>>>> for i in x:... print i

Page 546: Python @NCKU CSIE

Use a Generator>>>>>> x = (i**2 for i in range(5))>>> x = (i**2 for i in range(5))>>>>>> x = (i**2 for i in range(5))>>> x>>> x = (i**2 for i in range(5))>>> x<generator object <genexpr> at 0x110494690>>>>

>>> x = (i**2 for i in range(5))>>> x<generator object <genexpr> at 0x110494690>>>> for i in x:

>>> x = (i**2 for i in range(5))>>> x<generator object <genexpr> at 0x110494690>>>> for i in x:...

>>> x = (i**2 for i in range(5))>>> x<generator object <genexpr> at 0x110494690>>>> for i in x:... print i

>>> x = (i**2 for i in range(5))>>> x<generator object <genexpr> at 0x110494690>>>> for i in x:... print i...

Page 547: Python @NCKU CSIE

Use a Generator>>>>>> x = (i**2 for i in range(5))>>> x = (i**2 for i in range(5))>>>>>> x = (i**2 for i in range(5))>>> x>>> x = (i**2 for i in range(5))>>> x<generator object <genexpr> at 0x110494690>>>>

>>> x = (i**2 for i in range(5))>>> x<generator object <genexpr> at 0x110494690>>>> for i in x:

>>> x = (i**2 for i in range(5))>>> x<generator object <genexpr> at 0x110494690>>>> for i in x:...

>>> x = (i**2 for i in range(5))>>> x<generator object <genexpr> at 0x110494690>>>> for i in x:... print i

>>> x = (i**2 for i in range(5))>>> x<generator object <genexpr> at 0x110494690>>>> for i in x:... print i...

>>> x = (i**2 for i in range(5))>>> x<generator object <genexpr> at 0x110494690>>>> for i in x:... print i...014916>>>

Page 548: Python @NCKU CSIE

Help Yourself

Page 549: Python @NCKU CSIE

>>>

Help

Page 550: Python @NCKU CSIE

>>>>>> help(reduce)

Help

Page 551: Python @NCKU CSIE

>>>>>> help(reduce)Help on built-in function reduce in module __builtin__:

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y,

Help

Page 552: Python @NCKU CSIE

>>>>>> help(reduce)Help on built-in function reduce in module __builtin__:

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y,

__builtin__:

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates

Help

Page 553: Python @NCKU CSIE

>>>>>> help(reduce)Help on built-in function reduce in module __builtin__:

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y,

__builtin__:

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is

Help

Page 554: Python @NCKU CSIE

>>>>>> help(reduce)Help on built-in function reduce in module __builtin__:

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y,

__builtin__:

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items

Help

Page 555: Python @NCKU CSIE

>>>>>> help(reduce)Help on built-in function reduce in module __builtin__:

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y,

__builtin__:

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items

reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the sequence in the calculation, and

Help

Page 556: Python @NCKU CSIE

>>>>>> help(reduce)Help on built-in function reduce in module __builtin__:

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y,

__builtin__:

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items

reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the sequence in the calculation, and

> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the sequence in the calculation, and serves as a default when the

Help

Page 557: Python @NCKU CSIE

>>>>>> help(reduce)Help on built-in function reduce in module __builtin__:

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y,

__builtin__:

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items

reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the sequence in the calculation, and

> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the sequence in the calculation, and serves as a default when the

Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the sequence in the calculation, and serves as a default when the sequence is empty.

Help

Page 558: Python @NCKU CSIE

>>>>>> help(reduce)Help on built-in function reduce in module __builtin__:

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y,

__builtin__:

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items

reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the sequence in the calculation, and

> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the sequence in the calculation, and serves as a default when the

Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the sequence in the calculation, and serves as a default when the sequence is empty.

Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the sequence in the calculation, and serves as a default when the sequence is empty.(END)

Help

Page 559: Python @NCKU CSIE

>>>>>> help(reduce)Help on built-in function reduce in module __builtin__:

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y,

__builtin__:

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items

reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the sequence in the calculation, and

> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the sequence in the calculation, and serves as a default when the

Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the sequence in the calculation, and serves as a default when the sequence is empty.

Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the sequence in the calculation, and serves as a default when the sequence is empty.(END)

Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the sequence in the calculation, and serves as a default when the sequence is empty.(END)

Help

Page 560: Python @NCKU CSIE

>>>>>> help(reduce)Help on built-in function reduce in module __builtin__:

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y,

__builtin__:

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items

reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the sequence in the calculation, and

> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the sequence in the calculation, and serves as a default when the

Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the sequence in the calculation, and serves as a default when the sequence is empty.

Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the sequence in the calculation, and serves as a default when the sequence is empty.(END)

Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the sequence in the calculation, and serves as a default when the sequence is empty.(END)

press q

Help

Page 561: Python @NCKU CSIE

>>>>>> help(reduce)Help on built-in function reduce in module __builtin__:

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y,

__builtin__:

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is

reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items

reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the sequence in the calculation, and

> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the sequence in the calculation, and serves as a default when the

Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the sequence in the calculation, and serves as a default when the sequence is empty.

Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the sequence in the calculation, and serves as a default when the sequence is empty.(END)

Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the sequence in the calculation, and serves as a default when the sequence is empty.(END)

press q

>>> help(reduce)

>>>

Help

Page 562: Python @NCKU CSIE

pip

Page 563: Python @NCKU CSIE

pip

Package manager for Python

Download package in PyPI (Python Package Index)

Page 564: Python @NCKU CSIE

pip

Package manager for Python

Download package in PyPI (Python Package Index)

https://pypi.python.org/pypi

Page 565: Python @NCKU CSIE

Python Package Index

Page 566: Python @NCKU CSIE

Python Package Index

There are currently 31069 packages here.

Page 567: Python @NCKU CSIE

Install pip

$ apt-get install python-pip

For Ubuntu

$ brew install python

For OS X

Page 568: Python @NCKU CSIE

Install Pip on WindowsGo to https://pypi.python.org/pypi/distribute/0.6.45.

Download the source code, and unzip it.

Go to the directory and execute the following command.

> python.exe setup.py install

Go to http://www.lfd.uci.edu/~gohlke/pythonlibs/#pip, and download pip installer.

Page 569: Python @NCKU CSIE

Basic Command

$ pip install [package_name]

Install Package

$ pip uninstall [package_name]

Uninstall Package

$ pip search [package_name]

Search Package

Page 570: Python @NCKU CSIE

All Commandbundle create pybundles

freeze output all currently installed packages (exact versions) to stdout

help show available commandsinstall install packagessearch search PyPIuninstall uninstall packagesunzip unzip individual packageszip zip individual packages

Page 571: Python @NCKU CSIE

Install lxml$

Page 572: Python @NCKU CSIE

Install lxml$$ pip install lxml

Page 573: Python @NCKU CSIE

Install lxml$$ pip install lxml$ pip install lxmlDownloading/unpacking lxml$ pip install lxmlDownloading/unpacking lxml Downloading lxml-3.2.1.tar.gz (3.3MB): 3.3MB downloaded Running setup.py egg_info for package lxml /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url' warnings.warn(msg)

Downloading/unpacking lxml Downloading lxml-3.2.1.tar.gz (3.3MB): 3.3MB downloaded Running setup.py egg_info for package lxml /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url' warnings.warn(msg) Building lxml version 3.2.1.

Downloading lxml-3.2.1.tar.gz (3.3MB): 3.3MB downloaded Running setup.py egg_info for package lxml /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url' warnings.warn(msg) Building lxml version 3.2.1. Building without Cython.

3.3MB downloaded Running setup.py egg_info for package lxml /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url' warnings.warn(msg) Building lxml version 3.2.1. Building without Cython. Using build configuration of libxslt

Running setup.py egg_info for package lxml /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url' warnings.warn(msg) Building lxml version 3.2.1. Building without Cython. Using build configuration of libxslt 1.1.26

lxml /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url' warnings.warn(msg) Building lxml version 3.2.1. Building without Cython. Using build configuration of libxslt 1.1.26

/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url' warnings.warn(msg) Building lxml version 3.2.1. Building without Cython. Using build configuration of libxslt 1.1.26 warning: no previously-included files

Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url' warnings.warn(msg) Building lxml version 3.2.1. Building without Cython. Using build configuration of libxslt 1.1.26 warning: no previously-included files found matching '*.py'

lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url' warnings.warn(msg) Building lxml version 3.2.1. Building without Cython. Using build configuration of libxslt 1.1.26 warning: no previously-included files found matching '*.py' warning: no files found matching

UserWarning: Unknown distribution option: 'bugtrack_url' warnings.warn(msg) Building lxml version 3.2.1. Building without Cython. Using build configuration of libxslt 1.1.26 warning: no previously-included files found matching '*.py' warning: no files found matching '*.txt' under directory 'src/lxml/tests'

'bugtrack_url' warnings.warn(msg) Building lxml version 3.2.1. Building without Cython. Using build configuration of libxslt 1.1.26 warning: no previously-included files found matching '*.py' warning: no files found matching '*.txt' under directory 'src/lxml/tests'Installing collected packages: lxml

warnings.warn(msg) Building lxml version 3.2.1. Building without Cython. Using build configuration of libxslt 1.1.26 warning: no previously-included files found matching '*.py' warning: no files found matching '*.txt' under directory 'src/lxml/tests'Installing collected packages: lxml Running setup.py install for lxml

Building lxml version 3.2.1. Building without Cython. Using build configuration of libxslt 1.1.26 warning: no previously-included files found matching '*.py' warning: no files found matching '*.txt' under directory 'src/lxml/tests'Installing collected packages: lxml Running setup.py install for lxml /usr/local/Cellar/python/2.7.5/

Building without Cython. Using build configuration of libxslt 1.1.26 warning: no previously-included files found matching '*.py' warning: no files found matching '*.txt' under directory 'src/lxml/tests'Installing collected packages: lxml Running setup.py install for lxml /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/

Using build configuration of libxslt 1.1.26 warning: no previously-included files found matching '*.py' warning: no files found matching '*.txt' under directory 'src/lxml/tests'Installing collected packages: lxml Running setup.py install for lxml /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267:

1.1.26 warning: no previously-included files found matching '*.py' warning: no files found matching '*.txt' under directory 'src/lxml/tests'Installing collected packages: lxml Running setup.py install for lxml /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option:

warning: no previously-included files found matching '*.py' warning: no files found matching '*.txt' under directory 'src/lxml/tests'Installing collected packages: lxml Running setup.py install for lxml /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'

found matching '*.py' warning: no files found matching '*.txt' under directory 'src/lxml/tests'Installing collected packages: lxml Running setup.py install for lxml /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url' warnings.warn(msg) Building lxml version 3.2.1.

warning: no files found matching '*.txt' under directory 'src/lxml/tests'Installing collected packages: lxml Running setup.py install for lxml /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url' warnings.warn(msg) Building lxml version 3.2.1. Building without Cython.

'*.txt' under directory 'src/lxml/tests'Installing collected packages: lxml Running setup.py install for lxml /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url' warnings.warn(msg) Building lxml version 3.2.1. Building without Cython. Using build configuration of libxslt

Installing collected packages: lxml Running setup.py install for lxml /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url' warnings.warn(msg) Building lxml version 3.2.1. Building without Cython. Using build configuration of libxslt 1.1.26

Running setup.py install for lxml /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url' warnings.warn(msg) Building lxml version 3.2.1. Building without Cython. Using build configuration of libxslt 1.1.26 building 'lxml.etree' extension

/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url' warnings.warn(msg) Building lxml version 3.2.1. Building without Cython. Using build configuration of libxslt 1.1.26 building 'lxml.etree' extension cc -fno-strict-aliasing -fno-common -

Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url' warnings.warn(msg) Building lxml version 3.2.1. Building without Cython. Using build configuration of libxslt 1.1.26 building 'lxml.etree' extension cc -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/

lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url' warnings.warn(msg) Building lxml version 3.2.1. Building without Cython. Using build configuration of libxslt 1.1.26 building 'lxml.etree' extension cc -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3

'bugtrack_url' warnings.warn(msg) Building lxml version 3.2.1. Building without Cython. Using build configuration of libxslt 1.1.26 building 'lxml.etree' extension cc -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/libxml2 -I/private/var/folders/yx/

Building lxml version 3.2.1. Building without Cython. Using build configuration of libxslt 1.1.26 building 'lxml.etree' extension cc -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/libxml2 -I/private/var/folders/yx/3cgqr5y50vnf9ts91m5x073r0000gn/T/pip-build-KuoE0/lxml/src/lxml/includes -I/usr/local/

Building without Cython. Using build configuration of libxslt 1.1.26 building 'lxml.etree' extension cc -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/libxml2 -I/private/var/folders/yx/3cgqr5y50vnf9ts91m5x073r0000gn/T/pip-build-KuoE0/lxml/src/lxml/includes -I/usr/local/Cellar/python/2.7.5/Frameworks/

Using build configuration of libxslt 1.1.26 building 'lxml.etree' extension cc -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/libxml2 -I/private/var/folders/yx/3cgqr5y50vnf9ts91m5x073r0000gn/T/pip-build-KuoE0/lxml/src/lxml/includes -I/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/

1.1.26 building 'lxml.etree' extension cc -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/libxml2 -I/private/var/folders/yx/3cgqr5y50vnf9ts91m5x073r0000gn/T/pip-build-KuoE0/lxml/src/lxml/includes -I/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.etree.c -o

cc -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/libxml2 -I/private/var/folders/yx/3cgqr5y50vnf9ts91m5x073r0000gn/T/pip-build-KuoE0/lxml/src/lxml/includes -I/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.etree.o -flat_namespace

dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/libxml2 -I/private/var/folders/yx/3cgqr5y50vnf9ts91m5x073r0000gn/T/pip-build-KuoE0/lxml/src/lxml/includes -I/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.etree.o -flat_namespace clang: warning: argument unused during

opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/libxml2 -I/private/var/folders/yx/3cgqr5y50vnf9ts91m5x073r0000gn/T/pip-build-KuoE0/lxml/src/lxml/includes -I/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.etree.o -flat_namespace clang: warning: argument unused during compilation: '-flat_namespace'

-Wall -Wstrict-prototypes -I/usr/include/libxml2 -I/private/var/folders/yx/3cgqr5y50vnf9ts91m5x073r0000gn/T/pip-build-KuoE0/lxml/src/lxml/includes -I/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.etree.o -flat_namespace clang: warning: argument unused during compilation: '-flat_namespace' src/lxml/lxml.etree.c:136289:17:

libxml2 -I/private/var/folders/yx/3cgqr5y50vnf9ts91m5x073r0000gn/T/pip-build-KuoE0/lxml/src/lxml/includes -I/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.etree.o -flat_namespace clang: warning: argument unused during compilation: '-flat_namespace' src/lxml/lxml.etree.c:136289:17: warning: enumeration value

3cgqr5y50vnf9ts91m5x073r0000gn/T/pip-build-KuoE0/lxml/src/lxml/includes -I/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.etree.o -flat_namespace clang: warning: argument unused during compilation: '-flat_namespace' src/lxml/lxml.etree.c:136289:17: warning: enumeration value '__pyx_e_4lxml_5etree_PARSER_DATA_INVALID'

KuoE0/lxml/src/lxml/includes -I/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.etree.o -flat_namespace clang: warning: argument unused during compilation: '-flat_namespace' src/lxml/lxml.etree.c:136289:17: warning: enumeration value '__pyx_e_4lxml_5etree_PARSER_DATA_INVALID' not handled in switch [-Wswitch]

Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.etree.o -flat_namespace clang: warning: argument unused during compilation: '-flat_namespace' src/lxml/lxml.etree.c:136289:17: warning: enumeration value '__pyx_e_4lxml_5etree_PARSER_DATA_INVALID' not handled in switch [-Wswitch] switch (__pyx_v_doc_ref->_type) {

python2.7 -c src/lxml/lxml.etree.c -o build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.etree.o -flat_namespace clang: warning: argument unused during compilation: '-flat_namespace' src/lxml/lxml.etree.c:136289:17: warning: enumeration value '__pyx_e_4lxml_5etree_PARSER_DATA_INVALID' not handled in switch [-Wswitch] switch (__pyx_v_doc_ref->_type) { ^

lxml.etree.o -flat_namespace clang: warning: argument unused during compilation: '-flat_namespace' src/lxml/lxml.etree.c:136289:17: warning: enumeration value '__pyx_e_4lxml_5etree_PARSER_DATA_INVALID' not handled in switch [-Wswitch] switch (__pyx_v_doc_ref->_type) { ^ src/lxml/lxml.etree.c:140375:72: warning: incompatible pointer types passing

clang: warning: argument unused during compilation: '-flat_namespace' src/lxml/lxml.etree.c:136289:17: warning: enumeration value '__pyx_e_4lxml_5etree_PARSER_DATA_INVALID' not handled in switch [-Wswitch] switch (__pyx_v_doc_ref->_type) { ^ src/lxml/lxml.etree.c:140375:72: warning: incompatible pointer types passing 'struct __pyx_obj_4lxml_5etree__BaseContext

compilation: '-flat_namespace' src/lxml/lxml.etree.c:136289:17: warning: enumeration value '__pyx_e_4lxml_5etree_PARSER_DATA_INVALID' not handled in switch [-Wswitch] switch (__pyx_v_doc_ref->_type) { ^ src/lxml/lxml.etree.c:140375:72: warning: incompatible pointer types passing 'struct __pyx_obj_4lxml_5etree__BaseContext *' to parameter of type 'struct

src/lxml/lxml.etree.c:136289:17: warning: enumeration value '__pyx_e_4lxml_5etree_PARSER_DATA_INVALID' not handled in switch [-Wswitch] switch (__pyx_v_doc_ref->_type) { ^ src/lxml/lxml.etree.c:140375:72: warning: incompatible pointer types passing 'struct __pyx_obj_4lxml_5etree__BaseContext *' to parameter of type 'struct __pyx_obj_4lxml_5etree__XSLTContext *' [-

warning: enumeration value '__pyx_e_4lxml_5etree_PARSER_DATA_INVALID' not handled in switch [-Wswitch] switch (__pyx_v_doc_ref->_type) { ^ src/lxml/lxml.etree.c:140375:72: warning: incompatible pointer types passing 'struct __pyx_obj_4lxml_5etree__BaseContext *' to parameter of type 'struct __pyx_obj_4lxml_5etree__XSLTContext *' [-Wincompatible-pointer-types]

'__pyx_e_4lxml_5etree_PARSER_DATA_INVALID' not handled in switch [-Wswitch] switch (__pyx_v_doc_ref->_type) { ^ src/lxml/lxml.etree.c:140375:72: warning: incompatible pointer types passing 'struct __pyx_obj_4lxml_5etree__BaseContext *' to parameter of type 'struct __pyx_obj_4lxml_5etree__XSLTContext *' [-Wincompatible-pointer-types] __pyx_t_1 = ((PyObject

not handled in switch [-Wswitch] switch (__pyx_v_doc_ref->_type) { ^ src/lxml/lxml.etree.c:140375:72: warning: incompatible pointer types passing 'struct __pyx_obj_4lxml_5etree__BaseContext *' to parameter of type 'struct __pyx_obj_4lxml_5etree__XSLTContext *' [-Wincompatible-pointer-types] __pyx_t_1 = ((PyObject *)__pyx_f_4lxml_5etree_12_XSLTContext__copy

switch (__pyx_v_doc_ref->_type) { ^ src/lxml/lxml.etree.c:140375:72: warning: incompatible pointer types passing 'struct __pyx_obj_4lxml_5etree__BaseContext *' to parameter of type 'struct __pyx_obj_4lxml_5etree__XSLTContext *' [-Wincompatible-pointer-types] __pyx_t_1 = ((PyObject *)__pyx_f_4lxml_5etree_12_XSLTContext__copy(((struct

{ ^ src/lxml/lxml.etree.c:140375:72: warning: incompatible pointer types passing 'struct __pyx_obj_4lxml_5etree__BaseContext *' to parameter of type 'struct __pyx_obj_4lxml_5etree__XSLTContext *' [-Wincompatible-pointer-types] __pyx_t_1 = ((PyObject *)__pyx_f_4lxml_5etree_12_XSLTContext__copy(((struct __pyx_obj_4lxml_5etree__BaseContext

^ src/lxml/lxml.etree.c:140375:72: warning: incompatible pointer types passing 'struct __pyx_obj_4lxml_5etree__BaseContext *' to parameter of type 'struct __pyx_obj_4lxml_5etree__XSLTContext *' [-Wincompatible-pointer-types] __pyx_t_1 = ((PyObject *)__pyx_f_4lxml_5etree_12_XSLTContext__copy(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self->_context))); if (unlikely(!

src/lxml/lxml.etree.c:140375:72: warning: incompatible pointer types passing 'struct __pyx_obj_4lxml_5etree__BaseContext *' to parameter of type 'struct __pyx_obj_4lxml_5etree__XSLTContext *' [-Wincompatible-pointer-types] __pyx_t_1 = ((PyObject *)__pyx_f_4lxml_5etree_12_XSLTContext__copy(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self->_context))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2];

warning: incompatible pointer types passing 'struct __pyx_obj_4lxml_5etree__BaseContext *' to parameter of type 'struct __pyx_obj_4lxml_5etree__XSLTContext *' [-Wincompatible-pointer-types] __pyx_t_1 = ((PyObject *)__pyx_f_4lxml_5etree_12_XSLTContext__copy(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self->_context))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 543; __pyx_clineno =

'struct __pyx_obj_4lxml_5etree__BaseContext *' to parameter of type 'struct __pyx_obj_4lxml_5etree__XSLTContext *' [-Wincompatible-pointer-types] __pyx_t_1 = ((PyObject *)__pyx_f_4lxml_5etree_12_XSLTContext__copy(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self->_context))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L9;}

*' to parameter of type 'struct __pyx_obj_4lxml_5etree__XSLTContext *' [-Wincompatible-pointer-types] __pyx_t_1 = ((PyObject *)__pyx_f_4lxml_5etree_12_XSLTContext__copy(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self->_context))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L9;}

__pyx_obj_4lxml_5etree__XSLTContext *' [-Wincompatible-pointer-types] __pyx_t_1 = ((PyObject *)__pyx_f_4lxml_5etree_12_XSLTContext__copy(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self->_context))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L9;} ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Wincompatible-pointer-types] __pyx_t_1 = ((PyObject *)__pyx_f_4lxml_5etree_12_XSLTContext__copy(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self->_context))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L9;} ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

__pyx_t_1 = ((PyObject *)__pyx_f_4lxml_5etree_12_XSLTContext__copy(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self->_context))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L9;} ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lxml/lxml.etree.c:138310:138: note:

*)__pyx_f_4lxml_5etree_12_XSLTContext__copy(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self->_context))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L9;} ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lxml/lxml.etree.c:138310:138: note: passing argument to parameter

(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self->_context))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L9;} ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lxml/lxml.etree.c:138310:138: note: passing argument to parameter '__pyx_v_self' here

__pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self->_context))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L9;} ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lxml/lxml.etree.c:138310:138: note: passing argument to parameter '__pyx_v_self' here static struct

*)__pyx_v_self->_context))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L9;} ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lxml/lxml.etree.c:138310:138: note: passing argument to parameter '__pyx_v_self' here static struct __pyx_obj_4lxml_5etree__BaseContext

__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L9;} ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lxml/lxml.etree.c:138310:138: note: passing argument to parameter '__pyx_v_self' here static struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_f_4lxml_5etree_12_XSLTContext__copy(

__pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L9;} ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lxml/lxml.etree.c:138310:138: note: passing argument to parameter '__pyx_v_self' here static struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_f_4lxml_5etree_12_XSLTContext__copy(struct __pyx_obj_4lxml_5etree__XSLTContext

__LINE__; goto __pyx_L9;} ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lxml/lxml.etree.c:138310:138: note: passing argument to parameter '__pyx_v_self' here static struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_f_4lxml_5etree_12_XSLTContext__copy(struct __pyx_obj_4lxml_5etree__XSLTContext *__pyx_v_self) {

^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lxml/lxml.etree.c:138310:138: note: passing argument to parameter '__pyx_v_self' here static struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_f_4lxml_5etree_12_XSLTContext__copy(struct __pyx_obj_4lxml_5etree__XSLTContext *__pyx_v_self) {

^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lxml/lxml.etree.c:138310:138: note: passing argument to parameter '__pyx_v_self' here static struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_f_4lxml_5etree_12_XSLTContext__copy(struct __pyx_obj_4lxml_5etree__XSLTContext *__pyx_v_self) { ^

~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lxml/lxml.etree.c:138310:138: note: passing argument to parameter '__pyx_v_self' here static struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_f_4lxml_5etree_12_XSLTContext__copy(struct __pyx_obj_4lxml_5etree__XSLTContext *__pyx_v_self) { ^ src/lxml/lxml.etree.c:141781:70:

src/lxml/lxml.etree.c:138310:138: note: passing argument to parameter '__pyx_v_self' here static struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_f_4lxml_5etree_12_XSLTContext__copy(struct __pyx_obj_4lxml_5etree__XSLTContext *__pyx_v_self) { ^ src/lxml/lxml.etree.c:141781:70: warning: incompatible pointer types passing

passing argument to parameter '__pyx_v_self' here static struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_f_4lxml_5etree_12_XSLTContext__copy(struct __pyx_obj_4lxml_5etree__XSLTContext *__pyx_v_self) { ^ src/lxml/lxml.etree.c:141781:70: warning: incompatible pointer types passing 'struct __pyx_obj_4lxml_5etree__BaseContext

static struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_f_4lxml_5etree_12_XSLTContext__copy(struct __pyx_obj_4lxml_5etree__XSLTContext *__pyx_v_self) { ^ src/lxml/lxml.etree.c:141781:70: warning: incompatible pointer types passing 'struct __pyx_obj_4lxml_5etree__BaseContext *' to parameter of type 'struct __pyx_obj_4lxml_5etree__XSLTContext *' [-

__pyx_obj_4lxml_5etree__BaseContext *__pyx_f_4lxml_5etree_12_XSLTContext__copy(struct __pyx_obj_4lxml_5etree__XSLTContext *__pyx_v_self) { ^ src/lxml/lxml.etree.c:141781:70: warning: incompatible pointer types passing 'struct __pyx_obj_4lxml_5etree__BaseContext *' to parameter of type 'struct __pyx_obj_4lxml_5etree__XSLTContext *' [-Wincompatible-pointer-types]

*__pyx_f_4lxml_5etree_12_XSLTContext__copy(struct __pyx_obj_4lxml_5etree__XSLTContext *__pyx_v_self) { ^ src/lxml/lxml.etree.c:141781:70: warning: incompatible pointer types passing 'struct __pyx_obj_4lxml_5etree__BaseContext *' to parameter of type 'struct __pyx_obj_4lxml_5etree__XSLTContext *' [-Wincompatible-pointer-types] __pyx_t_1 = ((PyObject

struct __pyx_obj_4lxml_5etree__XSLTContext *__pyx_v_self) { ^ src/lxml/lxml.etree.c:141781:70: warning: incompatible pointer types passing 'struct __pyx_obj_4lxml_5etree__BaseContext *' to parameter of type 'struct __pyx_obj_4lxml_5etree__XSLTContext *' [-Wincompatible-pointer-types] __pyx_t_1 = ((PyObject *)__pyx_f_4lxml_5etree_12_XSLTContext__copy

*__pyx_v_self) { ^ src/lxml/lxml.etree.c:141781:70: warning: incompatible pointer types passing 'struct __pyx_obj_4lxml_5etree__BaseContext *' to parameter of type 'struct __pyx_obj_4lxml_5etree__XSLTContext *' [-Wincompatible-pointer-types] __pyx_t_1 = ((PyObject *)__pyx_f_4lxml_5etree_12_XSLTContext__copy(((struct

^ src/lxml/lxml.etree.c:141781:70: warning: incompatible pointer types passing 'struct __pyx_obj_4lxml_5etree__BaseContext *' to parameter of type 'struct __pyx_obj_4lxml_5etree__XSLTContext *' [-Wincompatible-pointer-types] __pyx_t_1 = ((PyObject *)__pyx_f_4lxml_5etree_12_XSLTContext__copy(((struct __pyx_obj_4lxml_5etree__BaseContext

^ src/lxml/lxml.etree.c:141781:70: warning: incompatible pointer types passing 'struct __pyx_obj_4lxml_5etree__BaseContext *' to parameter of type 'struct __pyx_obj_4lxml_5etree__XSLTContext *' [-Wincompatible-pointer-types] __pyx_t_1 = ((PyObject *)__pyx_f_4lxml_5etree_12_XSLTContext__copy(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_stylesheet->_context))); if

src/lxml/lxml.etree.c:141781:70: warning: incompatible pointer types passing 'struct __pyx_obj_4lxml_5etree__BaseContext *' to parameter of type 'struct __pyx_obj_4lxml_5etree__XSLTContext *' [-Wincompatible-pointer-types] __pyx_t_1 = ((PyObject *)__pyx_f_4lxml_5etree_12_XSLTContext__copy(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_stylesheet->_context))); if (unlikely(!__pyx_t_1)) {__pyx_filename =

warning: incompatible pointer types passing 'struct __pyx_obj_4lxml_5etree__BaseContext *' to parameter of type 'struct __pyx_obj_4lxml_5etree__XSLTContext *' [-Wincompatible-pointer-types] __pyx_t_1 = ((PyObject *)__pyx_f_4lxml_5etree_12_XSLTContext__copy(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_stylesheet->_context))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 680;

'struct __pyx_obj_4lxml_5etree__BaseContext *' to parameter of type 'struct __pyx_obj_4lxml_5etree__XSLTContext *' [-Wincompatible-pointer-types] __pyx_t_1 = ((PyObject *)__pyx_f_4lxml_5etree_12_XSLTContext__copy(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_stylesheet->_context))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto

*' to parameter of type 'struct __pyx_obj_4lxml_5etree__XSLTContext *' [-Wincompatible-pointer-types] __pyx_t_1 = ((PyObject *)__pyx_f_4lxml_5etree_12_XSLTContext__copy(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_stylesheet->_context))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

__pyx_obj_4lxml_5etree__XSLTContext *' [-Wincompatible-pointer-types] __pyx_t_1 = ((PyObject *)__pyx_f_4lxml_5etree_12_XSLTContext__copy(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_stylesheet->_context))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

Wincompatible-pointer-types] __pyx_t_1 = ((PyObject *)__pyx_f_4lxml_5etree_12_XSLTContext__copy(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_stylesheet->_context))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __pyx_L1_error;} ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

__pyx_t_1 = ((PyObject *)__pyx_f_4lxml_5etree_12_XSLTContext__copy(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_stylesheet->_context))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __pyx_L1_error;} ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

*)__pyx_f_4lxml_5etree_12_XSLTContext__copy(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_stylesheet->_context))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __pyx_L1_error;} ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lxml/lxml.etree.c:138310:138: note:

(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_stylesheet->_context))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __pyx_L1_error;} ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lxml/lxml.etree.c:138310:138: note: passing argument to parameter

__pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_stylesheet->_context))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __pyx_L1_error;} ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lxml/lxml.etree.c:138310:138: note: passing argument to parameter '__pyx_v_self' here

*)__pyx_v_stylesheet->_context))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __pyx_L1_error;} ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lxml/lxml.etree.c:138310:138: note: passing argument to parameter '__pyx_v_self' here static struct

(unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __pyx_L1_error;} ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lxml/lxml.etree.c:138310:138: note: passing argument to parameter '__pyx_v_self' here static struct __pyx_obj_4lxml_5etree__BaseContext

__pyx_f[2]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __pyx_L1_error;} ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lxml/lxml.etree.c:138310:138: note: passing argument to parameter '__pyx_v_self' here static struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_f_4lxml_5etree_12_XSLTContext__copy(

__pyx_clineno = __LINE__; goto __pyx_L1_error;} ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lxml/lxml.etree.c:138310:138: note: passing argument to parameter '__pyx_v_self' here static struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_f_4lxml_5etree_12_XSLTContext__copy(struct __pyx_obj_4lxml_5etree__XSLTContext

__pyx_L1_error;} ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lxml/lxml.etree.c:138310:138: note: passing argument to parameter '__pyx_v_self' here static struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_f_4lxml_5etree_12_XSLTContext__copy(struct __pyx_obj_4lxml_5etree__XSLTContext *__pyx_v_self) {

^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lxml/lxml.etree.c:138310:138: note: passing argument to parameter '__pyx_v_self' here static struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_f_4lxml_5etree_12_XSLTContext__copy(struct __pyx_obj_4lxml_5etree__XSLTContext *__pyx_v_self) {

^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lxml/lxml.etree.c:138310:138: note: passing argument to parameter '__pyx_v_self' here static struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_f_4lxml_5etree_12_XSLTContext__copy(struct __pyx_obj_4lxml_5etree__XSLTContext *__pyx_v_self) { ^

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lxml/lxml.etree.c:138310:138: note: passing argument to parameter '__pyx_v_self' here static struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_f_4lxml_5etree_12_XSLTContext__copy(struct __pyx_obj_4lxml_5etree__XSLTContext *__pyx_v_self) { ^ src/lxml/lxml.etree.c:160712:19:

src/lxml/lxml.etree.c:138310:138: note: passing argument to parameter '__pyx_v_self' here static struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_f_4lxml_5etree_12_XSLTContext__copy(struct __pyx_obj_4lxml_5etree__XSLTContext *__pyx_v_self) { ^ src/lxml/lxml.etree.c:160712:19: warning: expression result unused [-

passing argument to parameter '__pyx_v_self' here static struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_f_4lxml_5etree_12_XSLTContext__copy(struct __pyx_obj_4lxml_5etree__XSLTContext *__pyx_v_self) { ^ src/lxml/lxml.etree.c:160712:19: warning: expression result unused [-Wunused-value]

static struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_f_4lxml_5etree_12_XSLTContext__copy(struct __pyx_obj_4lxml_5etree__XSLTContext *__pyx_v_self) { ^ src/lxml/lxml.etree.c:160712:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^

__pyx_obj_4lxml_5etree__BaseContext *__pyx_f_4lxml_5etree_12_XSLTContext__copy(struct __pyx_obj_4lxml_5etree__XSLTContext *__pyx_v_self) { ^ src/lxml/lxml.etree.c:160712:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/

*__pyx_f_4lxml_5etree_12_XSLTContext__copy(struct __pyx_obj_4lxml_5etree__XSLTContext *__pyx_v_self) { ^ src/lxml/lxml.etree.c:160712:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/

struct __pyx_obj_4lxml_5etree__XSLTContext *__pyx_v_self) { ^ src/lxml/lxml.etree.c:160712:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note:

*__pyx_v_self) { ^ src/lxml/lxml.etree.c:160712:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT'

^ src/lxml/lxml.etree.c:160712:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj),

^ src/lxml/lxml.etree.c:160712:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )

src/lxml/lxml.etree.c:160712:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )

warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^

Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:162525:19:

PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:162525:19: warning: expression result unused [-

^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:162525:19: warning: expression result unused [-Wunused-value]

/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:162525:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t);

Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:162525:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^

include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:162525:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/

expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:162525:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/

( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:162525:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note:

_Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:162525:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT'

^ src/lxml/lxml.etree.c:162525:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj),

^ src/lxml/lxml.etree.c:162525:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )

src/lxml/lxml.etree.c:162525:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )

warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^

Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:168081:19:

PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:168081:19: warning: expression result unused [-

^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:168081:19: warning: expression result unused [-Wunused-value]

/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:168081:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t);

Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:168081:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^

include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:168081:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/

expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:168081:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/

( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:168081:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note:

_Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:168081:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT'

^ src/lxml/lxml.etree.c:168081:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj),

^ src/lxml/lxml.etree.c:168081:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )

src/lxml/lxml.etree.c:168081:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )

warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^

Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:170771:19:

PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:170771:19: warning: expression result unused [-

^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:170771:19: warning: expression result unused [-Wunused-value]

/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:170771:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t);

Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:170771:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^

include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:170771:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/

expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:170771:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/

( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:170771:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note:

_Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:170771:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT'

^ src/lxml/lxml.etree.c:170771:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj),

^ src/lxml/lxml.etree.c:170771:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )

src/lxml/lxml.etree.c:170771:19: warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )

warning: expression result unused [-Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^

Wunused-value] PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:12770:13:

PyObject_INIT(o, t); ^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:12770:13: warning: function

^ /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:12770:13: warning: function '__pyx_f_4lxml_5etree_displayNode' is not

/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:12770:13: warning: function '__pyx_f_4lxml_5etree_displayNode' is not needed and will not be emitted [-Wunneeded-

Frameworks/Python.framework/Versions/2.7/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:12770:13: warning: function '__pyx_f_4lxml_5etree_displayNode' is not needed and will not be emitted [-Wunneeded-internal-declaration]

include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:12770:13: warning: function '__pyx_f_4lxml_5etree_displayNode' is not needed and will not be emitted [-Wunneeded-internal-declaration] static void

expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:12770:13: warning: function '__pyx_f_4lxml_5etree_displayNode' is not needed and will not be emitted [-Wunneeded-internal-declaration] static void __pyx_f_4lxml_5etree_displayNode(xmlNode

( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:12770:13: warning: function '__pyx_f_4lxml_5etree_displayNode' is not needed and will not be emitted [-Wunneeded-internal-declaration] static void __pyx_f_4lxml_5etree_displayNode(xmlNode *__pyx_v_c_node, PyObject *__pyx_v_indent)

_Py_NewReference((PyObject *)(op)), (op) ) ^ src/lxml/lxml.etree.c:12770:13: warning: function '__pyx_f_4lxml_5etree_displayNode' is not needed and will not be emitted [-Wunneeded-internal-declaration] static void __pyx_f_4lxml_5etree_displayNode(xmlNode *__pyx_v_c_node, PyObject *__pyx_v_indent) {

^ src/lxml/lxml.etree.c:12770:13: warning: function '__pyx_f_4lxml_5etree_displayNode' is not needed and will not be emitted [-Wunneeded-internal-declaration] static void __pyx_f_4lxml_5etree_displayNode(xmlNode *__pyx_v_c_node, PyObject *__pyx_v_indent) { ^

^ src/lxml/lxml.etree.c:12770:13: warning: function '__pyx_f_4lxml_5etree_displayNode' is not needed and will not be emitted [-Wunneeded-internal-declaration] static void __pyx_f_4lxml_5etree_displayNode(xmlNode *__pyx_v_c_node, PyObject *__pyx_v_indent) { ^ 8 warnings generated.

src/lxml/lxml.etree.c:12770:13: warning: function '__pyx_f_4lxml_5etree_displayNode' is not needed and will not be emitted [-Wunneeded-internal-declaration] static void __pyx_f_4lxml_5etree_displayNode(xmlNode *__pyx_v_c_node, PyObject *__pyx_v_indent) { ^ 8 warnings generated. cc -bundle -undefined dynamic_lookup -

warning: function '__pyx_f_4lxml_5etree_displayNode' is not needed and will not be emitted [-Wunneeded-internal-declaration] static void __pyx_f_4lxml_5etree_displayNode(xmlNode *__pyx_v_c_node, PyObject *__pyx_v_indent) { ^ 8 warnings generated. cc -bundle -undefined dynamic_lookup -L/usr/local/lib -L/usr/local/opt/sqlite/lib

'__pyx_f_4lxml_5etree_displayNode' is not needed and will not be emitted [-Wunneeded-internal-declaration] static void __pyx_f_4lxml_5etree_displayNode(xmlNode *__pyx_v_c_node, PyObject *__pyx_v_indent) { ^ 8 warnings generated. cc -bundle -undefined dynamic_lookup -L/usr/local/lib -L/usr/local/opt/sqlite/lib build/temp.macosx-10.8-x86_64-2.7/src/lxml/

needed and will not be emitted [-Wunneeded-internal-declaration] static void __pyx_f_4lxml_5etree_displayNode(xmlNode *__pyx_v_c_node, PyObject *__pyx_v_indent) { ^ 8 warnings generated. cc -bundle -undefined dynamic_lookup -L/usr/local/lib -L/usr/local/opt/sqlite/lib build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.etree.o -lxslt -lexslt -lxml2 -lz -lm

internal-declaration] static void __pyx_f_4lxml_5etree_displayNode(xmlNode *__pyx_v_c_node, PyObject *__pyx_v_indent) { ^ 8 warnings generated. cc -bundle -undefined dynamic_lookup -L/usr/local/lib -L/usr/local/opt/sqlite/lib build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.etree.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.macosx-10.8-x86_64-2.7/lxml/

static void __pyx_f_4lxml_5etree_displayNode(xmlNode *__pyx_v_c_node, PyObject *__pyx_v_indent) { ^ 8 warnings generated. cc -bundle -undefined dynamic_lookup -L/usr/local/lib -L/usr/local/opt/sqlite/lib build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.etree.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.macosx-10.8-x86_64-2.7/lxml/etree.so

__pyx_f_4lxml_5etree_displayNode(xmlNode *__pyx_v_c_node, PyObject *__pyx_v_indent) { ^ 8 warnings generated. cc -bundle -undefined dynamic_lookup -L/usr/local/lib -L/usr/local/opt/sqlite/lib build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.etree.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.macosx-10.8-x86_64-2.7/lxml/etree.so building 'lxml.objectify' extension

*__pyx_v_c_node, PyObject *__pyx_v_indent) { ^ 8 warnings generated. cc -bundle -undefined dynamic_lookup -L/usr/local/lib -L/usr/local/opt/sqlite/lib build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.etree.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.macosx-10.8-x86_64-2.7/lxml/etree.so building 'lxml.objectify' extension cc -fno-strict-aliasing -fno-common -

{ ^ 8 warnings generated. cc -bundle -undefined dynamic_lookup -L/usr/local/lib -L/usr/local/opt/sqlite/lib build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.etree.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.macosx-10.8-x86_64-2.7/lxml/etree.so building 'lxml.objectify' extension cc -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/

^ 8 warnings generated. cc -bundle -undefined dynamic_lookup -L/usr/local/lib -L/usr/local/opt/sqlite/lib build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.etree.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.macosx-10.8-x86_64-2.7/lxml/etree.so building 'lxml.objectify' extension cc -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3

8 warnings generated. cc -bundle -undefined dynamic_lookup -L/usr/local/lib -L/usr/local/opt/sqlite/lib build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.etree.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.macosx-10.8-x86_64-2.7/lxml/etree.so building 'lxml.objectify' extension cc -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/

cc -bundle -undefined dynamic_lookup -L/usr/local/lib -L/usr/local/opt/sqlite/lib build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.etree.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.macosx-10.8-x86_64-2.7/lxml/etree.so building 'lxml.objectify' extension cc -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/libxml2 -I/private/var/folders/yx/

L/usr/local/lib -L/usr/local/opt/sqlite/lib build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.etree.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.macosx-10.8-x86_64-2.7/lxml/etree.so building 'lxml.objectify' extension cc -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/libxml2 -I/private/var/folders/yx/3cgqr5y50vnf9ts91m5x073r0000gn/T/pip-build-

build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.etree.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.macosx-10.8-x86_64-2.7/lxml/etree.so building 'lxml.objectify' extension cc -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/libxml2 -I/private/var/folders/yx/3cgqr5y50vnf9ts91m5x073r0000gn/T/pip-build-KuoE0/lxml/src/lxml/includes -I/usr/local/

lxml.etree.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.macosx-10.8-x86_64-2.7/lxml/etree.so building 'lxml.objectify' extension cc -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/libxml2 -I/private/var/folders/yx/3cgqr5y50vnf9ts91m5x073r0000gn/T/pip-build-KuoE0/lxml/src/lxml/includes -I/usr/local/Cellar/python/2.7.5/Frameworks/

-o build/lib.macosx-10.8-x86_64-2.7/lxml/etree.so building 'lxml.objectify' extension cc -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/libxml2 -I/private/var/folders/yx/3cgqr5y50vnf9ts91m5x073r0000gn/T/pip-build-KuoE0/lxml/src/lxml/includes -I/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/

etree.so building 'lxml.objectify' extension cc -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/libxml2 -I/private/var/folders/yx/3cgqr5y50vnf9ts91m5x073r0000gn/T/pip-build-KuoE0/lxml/src/lxml/includes -I/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.objectify.c -o

building 'lxml.objectify' extension cc -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/libxml2 -I/private/var/folders/yx/3cgqr5y50vnf9ts91m5x073r0000gn/T/pip-build-KuoE0/lxml/src/lxml/includes -I/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.objectify.c -o build/temp.macosx-10.8-x86_64-2.7/src/lxml/

cc -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/libxml2 -I/private/var/folders/yx/3cgqr5y50vnf9ts91m5x073r0000gn/T/pip-build-KuoE0/lxml/src/lxml/includes -I/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.objectify.c -o build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.objectify.o -flat_namespace

dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/libxml2 -I/private/var/folders/yx/3cgqr5y50vnf9ts91m5x073r0000gn/T/pip-build-KuoE0/lxml/src/lxml/includes -I/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.objectify.c -o build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.objectify.o -flat_namespace clang: warning: argument unused during

opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/libxml2 -I/private/var/folders/yx/3cgqr5y50vnf9ts91m5x073r0000gn/T/pip-build-KuoE0/lxml/src/lxml/includes -I/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.objectify.c -o build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.objectify.o -flat_namespace clang: warning: argument unused during compilation: '-flat_namespace'

-Wall -Wstrict-prototypes -I/usr/include/libxml2 -I/private/var/folders/yx/3cgqr5y50vnf9ts91m5x073r0000gn/T/pip-build-KuoE0/lxml/src/lxml/includes -I/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.objectify.c -o build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.objectify.o -flat_namespace clang: warning: argument unused during compilation: '-flat_namespace' cc -bundle -undefined dynamic_lookup -

libxml2 -I/private/var/folders/yx/3cgqr5y50vnf9ts91m5x073r0000gn/T/pip-build-KuoE0/lxml/src/lxml/includes -I/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.objectify.c -o build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.objectify.o -flat_namespace clang: warning: argument unused during compilation: '-flat_namespace' cc -bundle -undefined dynamic_lookup -L/usr/local/lib -L/usr/local/opt/sqlite/lib

3cgqr5y50vnf9ts91m5x073r0000gn/T/pip-build-KuoE0/lxml/src/lxml/includes -I/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.objectify.c -o build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.objectify.o -flat_namespace clang: warning: argument unused during compilation: '-flat_namespace' cc -bundle -undefined dynamic_lookup -L/usr/local/lib -L/usr/local/opt/sqlite/lib build/temp.macosx-10.8-x86_64-2.7/src/lxml/

KuoE0/lxml/src/lxml/includes -I/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.objectify.c -o build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.objectify.o -flat_namespace clang: warning: argument unused during compilation: '-flat_namespace' cc -bundle -undefined dynamic_lookup -L/usr/local/lib -L/usr/local/opt/sqlite/lib build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.objectify.o -lxslt -lexslt -lxml2 -lz

Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.objectify.c -o build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.objectify.o -flat_namespace clang: warning: argument unused during compilation: '-flat_namespace' cc -bundle -undefined dynamic_lookup -L/usr/local/lib -L/usr/local/opt/sqlite/lib build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.objectify.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.macosx-10.8-x86_64-2.7/

Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.objectify.c -o build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.objectify.o -flat_namespace clang: warning: argument unused during compilation: '-flat_namespace' cc -bundle -undefined dynamic_lookup -L/usr/local/lib -L/usr/local/opt/sqlite/lib build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.objectify.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.macosx-10.8-x86_64-2.7/lxml/objectify.so

python2.7 -c src/lxml/lxml.objectify.c -o build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.objectify.o -flat_namespace clang: warning: argument unused during compilation: '-flat_namespace' cc -bundle -undefined dynamic_lookup -L/usr/local/lib -L/usr/local/opt/sqlite/lib build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.objectify.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.macosx-10.8-x86_64-2.7/lxml/objectify.so

build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.objectify.o -flat_namespace clang: warning: argument unused during compilation: '-flat_namespace' cc -bundle -undefined dynamic_lookup -L/usr/local/lib -L/usr/local/opt/sqlite/lib build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.objectify.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.macosx-10.8-x86_64-2.7/lxml/objectify.so warning: no files found matching

lxml.objectify.o -flat_namespace clang: warning: argument unused during compilation: '-flat_namespace' cc -bundle -undefined dynamic_lookup -L/usr/local/lib -L/usr/local/opt/sqlite/lib build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.objectify.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.macosx-10.8-x86_64-2.7/lxml/objectify.so warning: no files found matching '*.txt' under directory 'src/lxml/tests'

clang: warning: argument unused during compilation: '-flat_namespace' cc -bundle -undefined dynamic_lookup -L/usr/local/lib -L/usr/local/opt/sqlite/lib build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.objectify.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.macosx-10.8-x86_64-2.7/lxml/objectify.so warning: no files found matching '*.txt' under directory 'src/lxml/tests'Successfully installed lxml

compilation: '-flat_namespace' cc -bundle -undefined dynamic_lookup -L/usr/local/lib -L/usr/local/opt/sqlite/lib build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.objectify.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.macosx-10.8-x86_64-2.7/lxml/objectify.so warning: no files found matching '*.txt' under directory 'src/lxml/tests'Successfully installed lxmlCleaning up...

cc -bundle -undefined dynamic_lookup -L/usr/local/lib -L/usr/local/opt/sqlite/lib build/temp.macosx-10.8-x86_64-2.7/src/lxml/lxml.objectify.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.macosx-10.8-x86_64-2.7/lxml/objectify.so warning: no files found matching '*.txt' under directory 'src/lxml/tests'Successfully installed lxmlCleaning up...$

Page 574: Python @NCKU CSIE

Use lxml>>>

Page 575: Python @NCKU CSIE

Use lxml>>>>>> import lxml

Page 576: Python @NCKU CSIE

Use lxml>>>>>> import lxml>>> import lxml>>>

Page 577: Python @NCKU CSIE

SimpleHTTPServer

Page 578: Python @NCKU CSIE

Launch a Web Server$

Page 579: Python @NCKU CSIE

Launch a Web Server$ $ pythom -m SimpleHTTPServer

Page 580: Python @NCKU CSIE

Launch a Web Server$ $ pythom -m SimpleHTTPServer$ pythom -m SimpleHTTPServerServing HTTP on 0.0.0.0 port 8000 ...

Page 581: Python @NCKU CSIE

Connect to http://localhost:8000

Page 582: Python @NCKU CSIE

Thank You for Your Listening.