A Byte of Python, v1.20 (for Python 2.x) (2005).pdf
(
337 KB
)
Pobierz
11307386 UNPDF
A Byte of Python
Swaroop C H
A Byte of Python
Swaroop C H
Copyright © 2003-2005 Swaroop C H
Abstract
This book will help you to learn the Python programming language, whether you are new to computers
or are an experienced programmer.
This book is released under the Creative Commons Attribution-NonCommercial-ShareAlike License 2.0 .
Table of Contents
Preface
...................................................................................................................... x
Who This Book Is For
.......................................................................................... x
History Lesson
................................................................................................... x
Status of the book
................................................................................................ x
Official Website
................................................................................................. xi
License Terms
................................................................................................... xi
Feedback
.......................................................................................................... xi
Something To Think About
.................................................................................. xi
1. Introduction
............................................................................................................ 1
Introduction
....................................................................................................... 1
Features of Python
.............................................................................................. 1
Summary
................................................................................................... 2
Why not Perl?
.................................................................................................... 3
What Programmers Say
........................................................................................ 3
2. Installing Python
..................................................................................................... 4
For Linux/BSD users
........................................................................................... 4
For Windows Users
............................................................................................. 4
Summary
........................................................................................................... 5
3. First Steps
.............................................................................................................. 6
Introduction
....................................................................................................... 6
Using the interpreter prompt
.................................................................................. 6
Choosing an Editor
.............................................................................................. 6
Using a Source File
............................................................................................. 7
Output
...................................................................................................... 7
How It Works
............................................................................................. 8
Executable Python programs
................................................................................. 8
Getting Help
...................................................................................................... 9
Summary
......................................................................................................... 10
4. The Basics
............................................................................................................ 11
Literal Constants
............................................................................................... 11
Numbers
......................................................................................................... 11
Strings
............................................................................................................ 11
Variables
......................................................................................................... 13
Identifier Naming
.............................................................................................. 13
Data Types
...................................................................................................... 14
Objects
........................................................................................................... 14
Output
.................................................................................................... 15
How It Works
........................................................................................... 15
Logical and Physical Lines
................................................................................. 15
Indentation
...................................................................................................... 17
Summary
......................................................................................................... 18
5. Operators and Expressions
....................................................................................... 19
Introduction
..................................................................................................... 19
Operators
......................................................................................................... 19
Operator Precedence
.......................................................................................... 21
Order of Evaluation
................................................................................... 22
Associativity
............................................................................................ 22
Expressions
...................................................................................................... 22
Using Expressions
..................................................................................... 22
Summary
......................................................................................................... 23
6. Control Flow
........................................................................................................ 24
Introduction
..................................................................................................... 24
The if statement
................................................................................................ 24
iv
A Byte of Python
Using the if statement
................................................................................ 24
How It Works
........................................................................................... 25
The while statement
........................................................................................... 26
Using the while statement
........................................................................... 26
The for loop
..................................................................................................... 27
Using the for statement
.............................................................................. 27
The break statement
........................................................................................... 28
Using the break statement
........................................................................... 28
The continue statement
....................................................................................... 30
Using the continue statement
....................................................................... 30
Summary
......................................................................................................... 30
7. Functions
............................................................................................................. 32
Introduction
..................................................................................................... 32
Defining a Function
................................................................................... 32
Function Parameters
.......................................................................................... 32
Using Function Parameters
......................................................................... 33
Local Variables
................................................................................................ 33
Using Local Variables
................................................................................ 34
Using the global statement
.......................................................................... 34
Default Argument Values
................................................................................... 35
Using Default Argument Values
.................................................................. 35
Keyword Arguments
.......................................................................................... 36
Using Keyword Arguments
......................................................................... 37
The return statement
.......................................................................................... 37
Using the literal statement
........................................................................... 38
DocStrings
....................................................................................................... 38
Using DocStrings
...................................................................................... 39
Summary
......................................................................................................... 40
8. Modules
............................................................................................................... 41
Introduction
..................................................................................................... 41
Using the sys module
................................................................................. 41
Byte-compiled .pyc files
..................................................................................... 42
The from..import statement
................................................................................. 42
A module's __name__
........................................................................................ 42
Using a module's __name__
........................................................................ 43
Making your own Modules
................................................................................. 43
Creating your own Modules
........................................................................ 43
from..import
............................................................................................. 44
The dir() function
.............................................................................................. 45
Using the dir function
................................................................................ 45
Summary
......................................................................................................... 46
9. Data Structures
...................................................................................................... 47
Introduction
..................................................................................................... 47
List
................................................................................................................ 47
Quick introduction to Objects and Classes
..................................................... 47
Using Lists
.............................................................................................. 47
Tuple
.............................................................................................................. 49
Using Tuples
............................................................................................ 49
Tuples and the print statement
..................................................................... 50
Dictionary
....................................................................................................... 51
Using Dictionaries
..................................................................................... 51
Sequences
........................................................................................................ 53
Using Sequences
....................................................................................... 53
References
....................................................................................................... 54
Objects and References
.............................................................................. 55
More about Strings
............................................................................................ 56
String Methods
......................................................................................... 56
Summary
......................................................................................................... 57
v
Plik z chomika:
Pinus000
Inne pliki z tego folderu:
A Byte of Python, v1.20 (for Python 2.x) (2005).pdf
(337 KB)
A Byte of Python, v1.92 (for Python 3.0) (2009).pdf
(608 KB)
A Learner's Guide to Programming Using the Python Language (2009).pdf
(17233 KB)
A Primer on Scientific Programming with Python (2009).pdf
(6983 KB)
Beginning Game Development with Python and Pygame - From Novice to Professional (2007).pdf
(7814 KB)
Inne foldery tego chomika:
-- ▣▣▣ ELEKTRONIKA ▣▣ ▬▬▬▬▬▬▬▬▬▬▬▬▬
Pliki dostępne do 01.06.2025
Pliki dostępne do 08.07.2024
Pliki dostępne do 19.01.2025
►Kurs Java
Zgłoś jeśli
naruszono regulamin