Python Without Fear, 1st edition
BRAND: PEARSON
eBook edition. 1 year Subscription. Dành cho Cá nhân | Trường ĐH, Nhóm, Thư Viện: Gọi 0915920514 để báo giá Pearson, Vital Source eBook hoặc mua Sách In
Tổng quan sách
Python không sợ hãi sẽ là cuốn sách lý tưởng cho những người đã từng lập trình bằng bất kỳ ngôn ngữ nào trước đây—chẳng hạn như C, C++, Basic hoặc Java—và muốn học Python một cách dễ dàng và đáng tin cậy nhất có thể. Nó cũng sẽ cung cấp một hướng dẫn dễ đọc giải thích cách thức hoạt động của Python. Nói tóm lại, đây là cuốn sách Python dành cho người mới bắt đầu đến trung cấp lý tưởng.
- Preface xviiAcknowledgments xxiAuthor Bio xxiii
- Chapter 1: Meet the Python 1A Brief History of Python 1How Python Is Different 2How This Book Works 3Installing Python 4Begin Using Python with IDLE 6Correcting Mistakes from Within IDLE 6Dealing with Ends of Lines 7Additional Help: Online Sources 8
- Chapter 2: A Python Safari: Numbers 9Python and Numbers 9Python and Floating-Point Numbers 14Assigning Numbers to Variables 17Variable-Naming Conventions in This Book 23Some Python Shortcuts 23
- Chapter 2 Summary 26
- Chapter 3: Your First Programs 29Temperatures Rising? 29Putting in a Print Message 35Syntax Summaries 36Getting String Input 41Getting Numeric Input 43Formatted Output String 46
- Chapter 3 Summary 50
- Chapter 4: Decisions and Looping 53Decisions Inside a Computer Program 53Conditional and Boolean Operators 55The if, elif, and else Keywords 56while: Looping the Loop 60 “Give Me a break” Statement 70
- Chapter 4 Summary 75
- Chapter 5: Python Lists 77The Python Way: The World Is Made of Collections 77Processing Lists with for 80Modifying Elements with for (You Can't!) 82Indexing and Slicing 85Copying Data to Slices 88Ranges 89List Functions and the in Keyword 97
- Chapter 5 Summary 99
- Chapter 6: List Comprehension and Enumeration 101Indexes and the enumerate Function 101The Format String Method Revisited 103Simple List Comprehension 106“Two-Dimensional” List Comprehension 112List Comprehension with Conditional 114
- Chapter 6 Summary 123
- Chapter 7: Python Strings 125Creating a String with Quote Marks 125Indexing and “Slicing” 127String/Number Conversions 130Stripping for Fun and Profit 135Let’s Split: The split Method 138Building Strings with Concatenation (+) 139The join Method 143
- Chapter 7 Summary 144
- Chapter 8: Single-Character Ops 147Naming Conventions in This
- Chapter 147Accessing Individual Characters (A Review) 148Getting Help with String Methods 148Testing Uppercase vs. Lowercase 149Converting Case of Letters 150Testing for Palindromes 151Converting to ASCII Code 159Converting ASCII to Character 160
- Chapter 8 Summary 166
- Chapter 9: Advanced Function Techniques 167Multiple Arguments 167Returning More Than One Value 168Arguments by Name 173Default Arguments 174Importing Functions from Modules 178
- Chapter 9 Summary 185
- Chapter 10: Local and Global Variables 187Local Variables, What Are They Good For? 187Locals vs. Globals 188Introducing the global Keyword 190The Python “Local Variable Trap” 190
- Chapter 10 Summary 204
- Chapter 11: File Ops 207Text Files vs. Binary Files 207The Op System (os) Module 208Open a File 211Let’s Write a Text File 213Read a Text File 216Files and Exception Handling 217Other File Modes 223
- Chapter 11 Summary 224
- Chapter 12: Dictionaries and Sets 227Why Do We Need Dictionaries, Ms. Librarian? 227Adding and Changing Key-Value Pairs 229Accessing Values 230Searching for Keys 231Converting Dictionaries to Lists 235All About Sets 241Operations on Sets 242
- Chapter 12 Summary 246
- Chapter 13: Matrixes: 2-D Lists 249Simple Matrixes 249Accessing Elements 250Irregular Matrixes and Length of a Row 251Multiplication (*) and Lists 252The Python Matrix Problem 253How to Create N*M Matrixes: The Solution 254How to Rotate a Matrix 261
- Chapter 13 Summary 268
- Chapter 14: Winning at Tic-Tac-Toe 271Design of a Tic-Tac-Toe Board 271Plan of This
- Chapter 273Python One-Line if/else 274The count Method for Lists 279Introducing the Computer Player 285
- Chapter 14 Summary 294
- Chapter 15: Classes and Objects I 295What’s an Object? 295Classes in Python 296The All-Important _ _init_ Method 301Design for a Database Class 303Defining Other Methods 309Design for a Point3D Class 310Point3D Class and Default Arguments 312Three-Dimensional Tic-Tac-Toe 312
- Chapter 15 Summary 318
- Chapter 16: Classes and Objects II 321Getting Help from Doc Strings 321Function Typing and “Overloading” 323Variable-Length Argument Lists 326Inheritance 331The Fraction Class 333Class Variables and Methods 337Instance Variables as “Default” Values 339
- Chapter 16 Summary 344
- Chapter 17: Conway’s Game of Life 347Game of Life: The Rules of the Game 348Generating the Neighbor Count 350Design of the Program 352Moving the Matrix Class to a Module 354The Famous Slider Pattern 358
- Chapter 17 Summary 364
- Chapter 18: Advanced Pythonic Techniques 367Generators 367Exploiting the Power of Generators 369Properties 375Decorators: Functions Enclosing Other Functions 382Python Decoration 385
- Chapter 18 Summary 389Appendix A: Python Operator Precedence Table 391Appendix B: Summary of Most Important Formatting Rules for Python 3.0 3931. Formatting Ordinary Text 3932. Formatting Arguments 3933. Specifying Order of Arguments 3934. Right Justification Within Field of Size N 3945. Left Justification Within Field of Size N 3946. Truncation: Limit Size of Print Field 3947. Combined Truncation and Justification 3958. Length and Precision of Floating-Point Numbers 3959. The Padding Character 395Appendix C: Glossary 397Index 407
