Worldwide Over 500,000 Copies Sold Learn Python— Fast! 2nd Edition Py .

1y ago
21 Views
3 Downloads
6.69 MB
548 Pages
Last View : 1m ago
Last Download : 2m ago
Upload by : Aliana Wahl
Transcription

2ND EDITION WORLDWIDE BEST SELLER OVER 500,000 COPIES SOLD In the first half of the book, you’ll learn basic programming concepts, such as variables, lists, classes, and loops, and practice writing clean code with exercises for each topic. You’ll also learn how to make your programs interactive and test your code safely before adding it to a project. In the second half, you’ll put your new knowledge into practice with three substantial projects: a Space Invaders–inspired arcade game, a set of data visualizations with Python’s handy libraries, and a simple web app you can deploy online. As you work through the book, you’ll learn how to: Use powerful Python libraries and tools, including Pygame, Matplotlib, Plotly, and Django Make 2D games that respond to keypresses and mouse clicks, and that increase in difficulty Use data to generate interactive visualizations Create and customize web apps and deploy them safely online Deal with mistakes and errors so you can solve your own programming problems This updated second edition has been thoroughly revised to reflect the latest in Python code and practices. The first half of the book includes improved coverage of topics like f-strings, constants, and managing data. In the second half, the code for the projects has been updated with better structure, cleaner syntax, and more popular and up-to-date libraries and tools, like Plotly and the latest version of Django. (For a full list of updates, see the Preface.) If you’ve been thinking about digging into programming, Python Crash Course will get you writing real programs fast. Why wait any longer? Start your engines and code! ABOUT THE AUTHOR Eric Matthes is a high school science, math, and programming teacher living in Alaska. He has been writing programs since he was five years old and is the author of the Python Flash Cards, also from No Starch Press. COVERS PYTHON 3.X “ I L I E F L AT .” This book uses a durable binding that won’t snap shut SHELVE IN: PROGRAMMING LANGUAGES/ PYTHON FSC FPO 39.95 ( 53.95 CDN) MATTHES T H E F I N E ST I N G E E K E N T E RTA I N M E N T w w w.nostarch.com PY THON 2ND EDITION PY THON CR A SH COURSE Python Crash Course is the world’s best-selling guide to the Python programming language. This fast-paced, thorough introduction to programming with Python will have you writing programs, solving problems, and making things that work in no time. LEARN PYTHON— FAST! CR ASH COURSE A H A N D S - O N , P R O J E C T - B A S E D I N T R O D U C T I O N T O P R O G R A M M I N G ERIC MAT THES

PRAISE FOR Python Crash Course “It has been interesting to see No Starch Press producing future classics that should be alongside the more traditional programming books. Python Crash Course is one of those books.” —Greg L aden, ScienceBlogs “Deals with some rather complex projects and lays them out in a consistent, logical, and pleasant manner that draws the reader into the subject.” —Full Circle M agazine “Well presented with good explanations of the code snippets. The book works with you, one small step at a time, building more complex code, explaining what’s going on all the way.” —FlickThrough R eviews “Learning Python with Python Crash Course was an extremely positive experience! A great choice if you’re new to Python.” —Mikke G oes Coding “Does what it says on the tin, and does it really well. . . . Presents a large number of useful exercises as well as three challenging and entertaining projects.” —R ealP ython.com “A fast-paced but comprehensive introduction to programming with Python, Python Crash Course is another superb book to add to your library and help you finally master Python.” —TutorialEdge.net “A brilliant option for complete beginners without any coding experience. If you’re looking for a solid, uncomplicated intro to this very deep language, I have to recommend this book.” —WhatPixel.com “Contains literally everything you need to know about Python and even more.” —FireBearStudio.com

Python Crash Course 2nd Edition A Hands-On, Project-Based Introduction to Programming b y E r ic M a t t h e s San Francisco

Python Crash Course, 2nd Edition. Copyright 2019 by Eric Matthes. All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-10: 1-59327-928-0 ISBN-13: 978-1-59327-928-8 Publisher: William Pollock Production Editor: Riley Hoffman Cover Illustration: Josh Ellingson Cover and Interior Design: Octopod Studios Developmental Editor: Liz Chadwick Technical Reviewer: Kenneth Love Copyeditor: Anne Marie Walker Compositors: Riley Hoffman and Happenstance Type-O-Rama Proofreader: James Fraleigh For information on distribution, translations, or bulk sales, please contact No Starch Press, Inc. directly: No Starch Press, Inc. 245 8th Street, San Francisco, CA 94103 phone: 1.415.863.9900; info@nostarch.com www.nostarch.com The Library of Congress has catalogued the first edition as follows: Matthes, Eric, 1972Python crash course : a hands-on, project-based introduction to programming / by Eric Matthes. pages cm Includes index. Summary: "A project-based introduction to programming in Python, with exercises. Covers general programming concepts, Python fundamentals, and problem solving. Includes three projects - how to create a simple video game, use data visualization techniques to make graphs and charts, and build an interactive web application"-- Provided by publisher. ISBN 978-1-59327-603-4 -- ISBN 1-59327-603-6 1. Python (Computer program language) I. Title. QA76.73.P98M38 2015 005.13'3--dc23 2015018135 No Starch Press and the No Starch Press logo are registered trademarks of No Starch Press, Inc. Other product and company names mentioned herein may be the trademarks of their respective owners. Rather than use a trademark symbol with every occurrence of a trademarked name, we are using the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The information in this book is distributed on an “As Is” basis, without warranty. While every precaution has been taken in the preparation of this work, neither the author nor No Starch Press, Inc. shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in it.

About the Author Eric Matthes is a high school science and math teacher living in Alaska, where he teaches an introductory Python course. He has been writing programs since he was five years old. Eric currently focuses on writing software that addresses inefficiencies in education and brings the benefits of open source software to the field of education. In his spare time he enjoys climbing mountains and spending time with his family. About the Technical Reviewer Kenneth Love has been a Python programmer, teacher, and conference organizer for many years. He has spoken and taught at many conferences, been a Python and Django freelancer, and is currently a software engineer for O’Reilly Media. Kenneth is co-creator of the django-braces package, which provides several handy mixins for Django’s class-based views. You can keep up with him on Twitter at @kennethlove.

For my father, who always made time to answer my questions about programming, and for Ever, who is just beginning to ask me his questions

Brief Contents Preface to the Second Edition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvii Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxi Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxiii Part I: Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Chapter 1: Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Chapter 2: Variables and Simple Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Chapter 3: Introducing Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Chapter 4: Working with Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 Chapter 5: if Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 Chapter 6: Dictionaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 Chapter 7: User Input and while Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 Chapter 8: Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 Chapter 9: Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 Chapter 10: Files and Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 Chapter 11: Testing Your Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 Part II: Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 Project 1: Alien Invasion Chapter 12: A Ship that Fires Bullets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 Chapter 13: Aliens! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255 Chapter 14: Scoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279

Project 2: Data Visualization Chapter 15: Generating Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305 Chapter 16: Downloading Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333 Chapter 17: Working with APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359 Project 3: Web Applications Chapter 18: Getting Started with Django . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379 Chapter 19: User Accounts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409 Chapter 20: Styling and Deploying an App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437 Afterword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465 Appendix A: Installation and Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467 Appendix B: Text Editors and IDEs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473 Appendix C: Getting Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479 Appendix D: Using Git for Version Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495 x   Brief Contents

Conte nt s in De ta il Preface to the Second Edition xxvii Acknowledgments xxxi Introduction Who Is This Book For? . . . . . . . . What Can You Expect to Learn? . Online Resources . . . . . . . . . . . Why Python? . . . . . . . . . . . . . . xxxiii . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxiv xxxiv . xxxv xxxvi Part I: Basics 1 1 Getting Started 3 Setting Up Your Programming Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Python Versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Running Snippets of Python Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . About the Sublime Text Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Python on Different Operating Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Python on Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Python on macOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Python on Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Running a Hello World Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Configuring Sublime Text to Use the Correct Python Version . . . . . . . . . . . . . . Running hello world.py . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Running Python Programs from a Terminal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . On Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . On macOS and Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 1-1: python.org . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 1-2: Hello World Typos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 1-3: Infinite Skills . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 . 4 . 4 . 4 . 5 . 5 . 7 . 8 . 9 . 9 10 11 12 12 12 13 13 13 13 2 Variables and Simple Data Types 15 What Really Happens When You Run hello world.py . . . . . . . . . . . . . . . . . . . . . . . . . Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Naming and Using Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Avoiding Name Errors When Using Variables . . . . . . . . . . . . . . . . . . . . . . . . Variables Are Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 2-1: Simple Message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 2-2: Simple Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 16 17 17 18 19 19

Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Changing Case in a String with Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . Using Variables in Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Adding Whitespace to Strings with Tabs or Newlines . . . . . . . . . . . . . . . . . . . Stripping Whitespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Avoiding Syntax Errors with Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 2-3: Personal Message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 2-4: Name Cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 2-5: Famous Quote . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 2-6: Famous Quote 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 2-7: Stripping Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Integers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Floats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Integers and Floats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Underscores in Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Multiple Assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 2-8: Number Eight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 2-9: Favorite Number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . How Do You Write Comments? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . What Kind of Comments Should You Write? . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 2-10: Adding Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Zen of Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 2-11: Zen of Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Introducing Lists What Is a List? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Accessing Elements in a List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Index Positions Start at 0, Not 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using Individual Values from a List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 3-1: Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 3-2: Greetings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 3-3: Your Own List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Changing, Adding, and Removing Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Modifying Elements in a List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Adding Elements to a List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Removing Elements from a List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 3-4: Guest List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 3-5: Changing Guest List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 3-6: More Guests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 3-7: Shrinking Guest List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Organizing a List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Sorting a List Permanently with the sort() Method . . . . . . . . . . . . . . . . . . . . . . Sorting a List Temporarily with the sorted() Function . . . . . . . . . . . . . . . . . . . . Printing a List in Reverse Order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Finding the Length of a List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 3-8: Seeing the World . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 3-9: Dinner Guests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 3-10: Every Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii   Contents in Detail 19 20 21 22 22 24 25 25 25 25 25 25 26 26 27 28 28 28 29 29 29 29 29 30 30 31 32 33 33 34 35 35 36 36 36 36 36 37 38 42 42 42 43 43 43 44 45 45 46 46 46

Avoiding Index Errors When Working with Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 Exercise 3-11: Intentional Error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 4 Working with Lists 49 Looping Through an Entire List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A Closer Look at Looping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Doing More Work Within a for Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Doing Something After a for Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Avoiding Indentation Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Forgetting to Indent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Forgetting to Indent Additional Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Indenting Unnecessarily . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Indenting Unnecessarily After the Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Forgetting the Colon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 4-1: Pizzas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 4-2: Animals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Making Numerical Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using the range() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using range() to Make a List of Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . Simple Statistics with a List of Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . List Comprehensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 4-3: Counting to Twenty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 4-4: One Million . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 4-5: Summing a Million . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 4-6: Odd Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 4-7: Threes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 4-8: Cubes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 4-9: Cube Comprehension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Working with Part of a List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Slicing a List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Looping Through a Slice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Copying a List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 4-10: Slices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 4-11: My Pizzas, Your Pizzas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 4-12: More Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Tuples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Defining a Tuple . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Looping Through All Values in a Tuple . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Writing over a Tuple . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 4-13: Buffet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Styling Your Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Style Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Indentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Line Length . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Blank Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Other Style Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 4-14: PEP 8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 4-15: Code Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 50 51 52 53 53 54 55 55 56 56 56 57 57 58 59 59 60 60 60 60 60 60 60 61 61 62 63 65 65 65 65 66 67 67 68 68 68 69 69 69 70 70 70 70 Contents in Detail   xiii

5 if Statements 71 A Simple Example . . . . . . . .

CR ASH COURSE PY THON CR ASH COURSE 2ND EDITION ERIC MATTHES SHELVE IN: PROGRAMMING LANGUAGES/ PYTHON 39.95 ( 53.95 CDN) LEARN PYTHON— FAST! COVERS PYTHON 3.X Python Crash Course is the world's best-selling guide to the Python programming language. This fast-paced, thorough introduction to programming with Python will

Related Documents:

Income Statement Highlights 2018 2017 Growth 2018 2017 Growth GH '000 GH '000 GH '000 GH '000 Group Company 0 500 1,000 1,500 2,000 2,500 3,000 3,500 2017 2018 ion Net Revenue - GOIL 6-500 500 1,500 2,500 3,500 4,500 5,500 2017 2018 n Net Revenue - GROUP 39.34 54.11 0 10 20 30 40 50 60 2017 2018 n Net Profit - GOIL 65.09 81.95 0 20 40 60 .

3.2 Examinations Pass Rate between Boys and Girls in Primary Schools in Malawi Data from the Malawi National Examinations Board (MANEB) (Figure 4) showed that the examinations pass rate for girls was much lower than that of boys. -500,000 1,000,000 1,500,000 2,000,000 2,500,000 3,000,000 3,500,000 4,000,000 4,500,000

Mar 31, 2017 · *Refer to the Franchise Disclosure Document for further detail. HIGH COST 243,750 4,000 5,000 6,500 1,500 500 1,200 5,000 750 4,500 2,500 525 5,000 280,725 LOW COST 87,750 0 0 1,000 1,000 0 0 500 0 1,500 1,500 525 5,000 98,775 Detailed Mapping

pas de neurones Arbre pas de neurones C.elegans 302 neurones C.elegans 302 neurones Mouche 1 000 000 neurones Mouche 1 000 000 neurones Rat 1 000 000 000 n. Rat 1 000 000 000 n. Humain 10 000 000 000 000 n. Humain 10 000 000 000 000 n. Le cerveau génère des mouvements ( comportement)

Clarification NFF TFF Capto Q ImpRes Nuclease treatment Capto Core 700 TFF. 0 10 000 20 000 30 000 40 000 50 000 60 000 70 000 80 000 90 000 0 10 000 20 000 30 000 40 000 50 000 60 000 70 000 80 000 90 000 /batch Capital Materials Consumables Labour Othe

Salary Guide 2021 14 Japan - 2021 Financial Services Front Office Salary Guide Investment Banking Fixed Income Sales ( Per Annum) Job Title Low Average High Analyst 5,000,000 6,000,000 9,000,000 Associate 7,000,000 10,000,000 13,000,000 VP 10,000,000 15,000,000 20,000,000 Director Investment Banking Equity Research

in-house salary in us yrs exps. in paid under 1 yr 1-2 yrs 3-5 yrs 6-9 yrs 10-15 yrs 15 yrs min salary 30,000 24,000 35,200 55,000 70,000 62,000 max salary 65,000 72,500 255,000 310,000 285,000 220,000 average 45,400 55,808 87,381 109,805 123,210 134,000 median 45,000 58,650 75,500 90,000 120,000 103,000 # of responses .

06 uefadirect 7.09 VEREINE Festbetrag Spiel- Leistungs- Marktpool Achtel- Viertel- Halb- Endspiel TOTAL prämien prämie finale finale finale EUR Gruppe A CFR 1907 Cluj 3 000 000 2 400 000 900 000 1 305 000 7 605 000 Chelsea FC 3 000 000 2 400 000 2 400 000 15 414 000 2 200 000 2 500 000 3 000 000 30 914 000