1. Trang chủ
  2. » Tất cả

Programming.for.Non-Programmers.How.to.Write.Your.Own.Software.Using.Python.Steven.F.Lott.2009

577 0 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Programming for Non-Programmers Release 2.5.1 Steven F Lott December 01, 2009 CONTENTS I How To Write Your Own Software Using Python Preface 1.1 Why Read This Book? 1.2 What Is This Book About? 1.3 Audience 1.4 Organization of This Book 1.5 Conventions Used in This Book 1.6 Python Example 1.7 Acknowledgements Getting Started 2.1 About Computers 2.2 About Programs 2.3 Let There Be Python: Downloading and Installing 2.4 Two Minimally-Geeky Problems : Examples of Things 2.5 Why Python is So Cool Best 5 11 11 12 Done by Customized Software 13 13 22 30 39 44 Using Python 49 3.1 Instant Gratification : The Simplest Possible Conversation 49 3.2 IDLE Time : Using Tools To Be More Productive 59 Arithmetic and Expressions 4.1 Simple Arithmetic : Numbers and Operators 4.2 Better Arithmetic Through Functions 4.3 Extra Functions: math and random 4.4 Special Ops : Binary Data and Operators 4.5 Peeking Under the Hood 65 65 77 83 89 96 Programming Essentials 5.1 Seeing Results : The print Statement 5.2 Turning Python Loose With a Script 5.3 Expressions, Constants and Variables 5.4 Assignment Bonus Features 5.5 Can We Get Your Input? 105 105 108 111 117 120 Some Self-Control 6.1 Truth and Logic : Boolean Data and Operators 6.2 Making Decisions : The Comparison Operators 6.3 Advanced Logic Operators 6.4 Processing Only When Necessary : The if Statement 127 127 133 137 140 i 6.5 6.6 6.7 While We Have More To Do : The for and while Statements 147 Becoming More Controlling 160 Turning Python Loose with More Sophisticated Scripts 167 Organizing Programs with Function Definitions 175 7.1 Adding New Verbs : The def Statement 175 7.2 Flexibility and Clarity : Optional Parameters, Keyword Arguments 188 7.3 A Few More Function Definition Tools 198 Getting Our Bearings 207 8.1 Where We’ve Been; Where We’re Going 207 Basic Sequential Collections of Data 9.1 Collecting Items in Sequence 9.2 Sequences of Characters : str and Unicode 9.3 Doubles, Triples, Quadruples : The tuple 9.4 Flexible Sequences : the list 9.5 Common List Design Patterns 211 211 217 238 248 264 10 Additional Processing Control Patterns 277 10.1 The Unexpected : The try and except statements 277 10.2 Looping Back : Iterators, the for statement, and the yield statement 298 11 More Data Collections 11.1 Collecting Items : The set 11.2 Mappings : The dict 11.3 Defining More Flexible Functions with Mappings 11.4 Another Mapping : The defaultdict 313 313 329 342 348 12 Working with Files 12.1 External Data and Files 12.2 Files II : Some Examples and Some Modules 12.3 Files III : The Grand Unification 353 353 367 379 13 Data + Processing = Objects 13.1 Objects: A Retrospective 13.2 Defining New Objects 13.3 Inheritance, Generalization and Specialization 13.4 Additional Classy Topics 13.5 Special Behavior Requires Special Methods 13.6 New Kinds of Numbers: Fractions and Currency 13.7 Creating New Types of Collections 389 389 396 410 426 436 443 454 14 Modules : The unit of software packaging and assembly 14.1 Module Definitions – Adding New Concepts 14.2 Essential Modules : The Python Library 14.3 Fixed-Point Numbers : Doing High Finance with decimal 14.4 Time and Date Processing : The time and datetime Modules 14.5 Text Processing and Pattern Matching : The re Module 465 465 481 489 494 509 15 Fit and Finish: Complete Programs 15.1 Wrapping and Packaging Our Solution 15.2 Architectural Patterns – A Family Tree 15.3 Professionalism : Additional Tips and Hints 521 521 529 533 ii 16 Appendix : Debugging 16.1 Let There Be Python: Downloading and Installing 16.2 Instant Gratification : The Simplest Possible Conversation 16.3 IDLE Time : Using Tools To Be More Productive 16.4 Simple Arithmetic : Numbers and Operators 16.5 Better Arithmetic Through Functions 16.6 Extra Functions: math and random 16.7 Special Ops : Binary Data and Operators 16.8 Peeking Under the Hood 16.9 Seeing Results : The print Statement 16.10 Expressions, Constants and Variables 16.11 Assignment Bonus Features 16.12 Can We Get Your Input? 16.13 Truth and Logic : Boolean Data and Operators 16.14 Making Decisions : The Comparison Operators 16.15 Processing Only When Necessary : The if Statement 16.16 While We Have More To Do : The for and while Statements 16.17 Becoming More Controlling 16.18 Turning Python Loose with More Sophisticated Scripts 16.19 Adding New Verbs : The def Statement 16.20 Common List Design Patterns 16.21 The Unexpected : The try and except statements 16.22 Looping Back : Iterators, the for statement, and the yield statement 16.23 Collecting Items : The set 16.24 External Data and Files 16.25 Files II : Some Examples and Some Modules 16.26 Files III : The Grand Unification 16.27 Defining New Objects 16.28 Inheritance, Generalization and Specialization 16.29 Additional Classy Topics 16.30 Special Behavior Requires Special Methods 16.31 Module Definitions – Adding New Concepts 16.32 Fixed-Point Numbers : Doing High Finance with decimal 16.33 Time and Date Processing : The time and datetime Modules 16.34 Text Processing and Pattern Matching : The re Module 16.35 Wrapping and Packaging Our Solution 543 543 543 545 545 546 546 546 546 547 547 547 548 548 548 548 549 550 551 552 553 554 555 556 556 557 557 557 558 559 559 560 560 561 561 561 17 Bibliography 17.1 Use Cases 17.2 Computer Science 17.3 Design Patterns 17.4 Languages 17.5 Project Management 17.6 Problem Domains 563 563 563 563 563 563 563 18 Indices and Tables 565 19 Other Back Matter 567 Bibliography 569 Module Index 571 iii iv Part I How To Write Your Own Software Using Python Programming for Non-Programmers, Release 2.5.1 Legal Notice This work is licensed under a Creative Commons License You are free to copy, distribute, display, and perform the work under the following conditions: • Attribution You must give the original author, Steven F Lott, credit • Noncommercial You may not use this work for commercial purposes • No Derivative Works You may not alter, transform, or build upon this work For any reuse or distribution, you must make clear to others the license terms of this work Programming for Non-Programmers, Release 2.5.1

Ngày đăng: 13/04/2019, 01:43

Xem thêm:

Mục lục

    I How To Write Your Own Software Using Python

    Why Read This Book?

    What Is This Book About?

    Organization of This Book

    Conventions Used in This Book

    Let There Be Python: Downloading and Installing

    Two Minimally-Geeky Problems : Examples of Things Best Done by Customized Software

    Why Python is So Cool

    Instant Gratification : The Simplest Possible Conversation

    IDLE Time : Using Tools To Be More Productive

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN