Giter Site home page Giter Site logo

jakevdp / whirlwindtourofpython Goto Github PK

View Code? Open in Web Editor NEW
3.7K 221.0 1.6K 1.2 MB

The Jupyter Notebooks behind my OReilly report, "A Whirlwind Tour of Python"

License: Creative Commons Zero v1.0 Universal

Jupyter Notebook 91.50% Makefile 0.88% Python 1.75% CSS 3.24% HTML 2.63%

whirlwindtourofpython's Introduction

A Whirlwind Tour of Python

Jake VanderPlas, Summer 2016

This repository contains the Jupyter Notebooks behind my O'Reilly report, A Whirlwind Tour of Python (free 100-page pdf).

A Whirlwind Tour of Python is a fast-paced introduction to essential components of the Python language for researchers and developers who are already familiar with programming in another language.

The material is particularly aimed at those who wish to use Python for data science and/or scientific programming, and in this capacity serves as an introduction to The Python Data Science Handbook (also with notebooks on github). These materials are adapted from courses and workshops I've given on these topics at University of Washington and at various conferences, meetings, and workshops around the world.

This material was written and tested using Python 3.5, and should work for any Python 3.X version. I have done my best to note places where the syntax of Python 2.X will differ.

Index

(Note: sometimes GitHub's notebook rendering can be slow or finicky. If you're having trouble with the following links, try viewing the material on nbviewer)

Notebook Index

  1. Introduction
  2. How to Run Python Code
  3. Basic Python Syntax
  4. Python Semantics: Variables
  5. Python Semantics: Operators
  6. Built-In Scalar Types
  7. Built-In Data Structures
  8. Control Flow Statements
  9. Defining Functions
  10. Errors and Exceptions
  11. Iterators
  12. List Comprehensions
  13. Generators and Generator Expressions
  14. Modules and Packages
  15. Strings and Regular Expressions
  16. Preview of Data Science Tools
  17. Resources for Further Learning
  18. Appendix: Code To Reproduce Figures

License and Citation

This material is released under the "No Rights Reserved" CC0 license, and thus you are free to re-use, modify, build-on, and enhance this material for any purpose. Read more about CC0 here.

If you do use this material, I would appreciate attribution. An attribution usually includes the title, author, publisher, and ISBN. For example:

A Whirlwind Tour of Python by Jake VanderPlas (O’Reilly). Copyright 2016 O’Reilly Media, Inc., 978-1-491-96465-1.

whirlwindtourofpython's People

Contributors

bonifacio2 avatar cdeil avatar jakevdp avatar michael-baker-content avatar morenoh149 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

whirlwindtourofpython's Issues

The // operator is not truncation for negative numbers.

In 04-Semantics-Operators.ipynb the // operator is described as
a // b | Floor division | Quotient of a and b, removing fractional parts
and
Floor division is true division with fractional parts truncated
Which works for the examples provided. However, in an active Jupyter notebook with negative numbers we see
-5/2 => -2.5
and
-5//2 => -3
This is what one would expect from floor division, but the text is a bit misleading in this case. From the text one would expect -2 here.

Add link to Python 3 sequences documentation

In *args and **kwargs: Flexible Arguments section of the link, there is this paragraph:

Here it is not the names args and kwargs that are important, but the * characters preceding them. args and kwargs are just the variable names often used by convention, short for "arguments" and "keyword arguments". The operative difference is the asterisk characters: a single * before a variable means "expand this as a sequence", while a double ** before a variable means "expand this as a dictionary". In fact, this syntax can be used not only with the function definition, but with the function call as well!

This seems to be the first time that sequence concept is mentioned. Given that there are many types of sequences and the concept is worth an aside, would it be a good idea to link to Sequence Types in the Python documentation?

Not sure if it is worth weaving in the broader concept of sequences or re-phrasing to restrict the example to just tuples.

Usage of "arrays"

The text seems to use the term "array" and "subarray" imprecisely or too liberally. Python actually does have an array type, which 1. does not seem to be covered in this text (not a real issue), but 2. is instead used to refer to lists and tuples (which I think can be misleading, so is an issue).

Trouble viewing .ipynb in GitHub

@jakevdp - really appreciate your intro to python w/ the focus on data sci. Am looking forward to picking up a copy of your handbook.

Having trouble viewing a few of the whirlwind tutorials in GitHub (might be them, not you).

So far, it looks as if the following pages are not rendering (I am able to read them by viewing the raw formats):

full notebook with cross-refs in the same document

I hope that this might be useful to someone - full notebook with cross-refs in the same document. In my case distributing ~20 separate notebooks is not really an option.

Please use nbviewer version, github rendering is really funky for hyperlinks.

http://nbviewer.jupyter.org/github/denfromufa/WhirlwindTourOfPython/blob/master/A%20Whirlwind%20Tour%20of%20Python.ipynb#Index

https://github.com/denfromufa/WhirlwindTourOfPython/blob/master/A%20Whirlwind%20Tour%20of%20Python.ipynb

Question about the book?

Congratulations for the book! I have a question regarding the production of the book. Have you written the book by using Jupyter notebooks or used LaTeX?

Import own files

I have read through the chapter on modules and packages. It does a good job of explaining importing standard libraries and 3rd party stuff from pypi. However, it's does not mention how to go about organising one's own code across files and importing it back and forth (or did I miss this?).

Is there a good reference for this (ideally in a similar style as this book)? Both for "regular" python uses as well as using notebooks.

Thanks for making this awesome resource available for free!

Question about continue

Hi, I am going through your (wonderful) Whirlwind Tour and got caught up on your explanation of the continue statement in part 7. The copy says you're using it to print a string of even numbers, but the string ends up being odd numbers. (And I think the block is coded to produce odd numbers.) Am I missing something or is that just a typo?

I think what the code says is "if the remainder of dividing n is 0, skip the rest of the loop". Is that what continue is for?

make html not working

I have tried to follow the instructions for building the blog using ubuntu 18.04.1 LTS, but I cannot seem to successfully run the make html command let alone the proceeding commands. Please help.

Typo: even instead of odd?

On page 40 there's a code listing printing a sequence of odd numbers with the following introduction:

Here is an example of using continue to print a string of even numbers. In this case, the result could be accomplished just as well with an if-else statement, but sometimes the continue statement can be a more convenient way to express the idea you have in mind:

In [7]: for n in range(20):
           # check if n is even
           if n % 2 == 0:
               continue
           print(n, end=' ')
1 3 5 7 9 11 13 15 17 19

Shouldn't the intro paragraph say odd instead of even?

Thank you for writing this book and publishing it for free! I really enjoy it and recommend it to my colleagues who have to dip their toes in some Python code.

Change statement about dictionaries?

Currently you have this statement about Python dictionaries:

http://nbviewer.jupyter.org/github/jakevdp/WhirlwindTourOfPython/blob/master/06-Built-in-Data-Structures.ipynb#Dictionaries

Keep in mind that dictionaries do not maintain any sense of order for the input parameters; this is by design. This lack of ordering allows dictionaries to be implemented very efficiently, so that random element access is very fast, regardless of the size of the dictionary (if you're curious how this works, read about the concept of a hash table).

Now that Python 3.6 has ordered and more efficient dictionaries, this statement should be changed, no? Maybe re-word the existing sentence starting with "This lack ..." or add a new one pointing to e.g. https://docs.python.org/3/whatsnew/3.6.html#new-dict-implementation ?

int precision

In 05-Built-in-Scalar-Types.ipynb it says:

C integers are fixed-precision, and usually overflow at some value (often near $2^{31}$ or $2^{63}$, depending on your system). Python integers are variable-precision, so you can do computations that would overflow in other languages:

I don't think it's correct to use the term "precision" to describe integers. They are as precise as they can be in both C and python. A better way to phrase it would be something like this:

C integers are limited to a fixed range, and usually overflow at some value (often near $2^{31}$ or $2^{63}$, depending on your system). Python integers are not limited to any fixed range, but are only limited by the available memory, so you can do computations that would overflow in other languages:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.