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
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller almanuckochwa. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $10.59. You're not tied to anything after your purchase.