Day One
Setting Up
- Python 2 and Python 3
- Running Snippets of Python Code
- Hello World!
Variables and Simple Data Types
- What Really Happens When You Run hello_world.py
- Variables
- Naming and Using Variables
- Avoiding Name Errors When Using Variables
- Strings
- Changing Case in a String with Methods
- Combining or Concatenating Strings
- Adding Whitespace to Strings with Tabs or Newlines
- Stripping Whitespace
- Avoiding Syntax Errors with Strings
- Printing in Python 2
- Numbers
- Integers
- Floats
- Avoiding Type Errors with the str() Function
- Integers in Python 2
- Comments
- How Do You Write Comments?
- What Kind of Comments Should You Write?
- The Zen of Python
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
- Changing, Adding, and Removing Elements
- Modifying Elements in a List
- Adding Elements to a List
- Removing Elements from a 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
- Avoiding Index Errors When Working with Lists
Day Two4. 5. 6.
4. Working with Lists
- 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
- Making Numerical Lists
- Using the range() Function
- Using range() to Make a List of Numbers
- Simple Statistics with a List of Numbers
- List Comprehensions
- Working with Part of a List
- Slicing a List
- Looping Through a Slice
- Copying a List
- Tuples
- Defining a Tuple
- Looping Through All Values in a Tuple
- Writing over a Tuple
- Styling Your Code
- The Style Guide
- Indentation
- Line Length
- Blank Lines
- Other Style Guidelines
5. if Statements
- A Simple Example
- Conditional Tests
- Checking for Equality
- Ignoring Case When Checking for Equality
- Checking for Inequality
- Numerical Comparisons
- Checking Multiple Conditions
- Checking Whether a Value Is in a List
- Checking Whether a Value Is Not in a List
- Boolean Expressions
- if Statements
- Simple if Statements
- if-else Statements
- The if -elif -else Chain
- Using Multiple elif Blocks
- Omitting the else Block
- Testing Multiple Conditions
- Using if Statements with Lists
- Checking for Special Items
- Checking That a List Is Not Empty
- Using Multiple Lists
- Styling Your if Statements
6. Dictionaries
- A Simple Dictionary
- Working with Dictionaries
- Accessing Values in a Dictionary
- Adding New Key-Value Pairs
- Starting with an Empty Dictionary
- Modifying Values in a Dictionary
- Removing Key-Value Pairs
- A Dictionary of Similar Objects
- Looping Through a Dictionary
- Looping Through All Key-Value Pairs
- Looping Through All the Keys in a Dictionary
- Looping Through a Dictionary’s Keys in Order
- Looping Through All Values in a Dictionary
- Nesting
- A List of Dictionaries
- A List in a Dictionary
- A Dictionary in a Dictionary
Day Three7.8.9.
7. User Input and while Loops
- How the input() Function Works
- Writing Clear Prompts
- Using int() to Accept Numerical Input
- The Modulo Operator
- Accepting Input in Python 2.7
- Introducing while Loops
- The while Loop in Action
- Letting the User Choose When to Quit
- Using a Flag
- Using break to Exit a Loop
- Using continue in a Loop
- Avoiding Infinite Loops
- Using a while Loop with Lists and Dictionaries
- Moving Items from One List to Another
- Removing All Instances of Specific Values from a List
- Filling a Dictionary with User Input
8. Functions
- Defining a Function
- Passing Information to a Function
- Arguments and Parameters
- Passing Arguments
- Positional Arguments
- Keyword Arguments
- Default Values
- Equivalent Function Calls
- Avoiding Argument Errors
- Return Values
- Returning a Simple Value
- Making an Argument Optional
- Returning a Dictionary
- Using a Function with a while Loop
- Passing a List
- Modifying a List in a Function
- Preventing a Function from Modifying a List
- Passing an Arbitrary Number of Arguments
- Mixing Positional and Arbitrary Arguments
- Using Arbitrary Keyword Arguments
- Storing Your Functions in Modules
- Importing an Entire Module
- Importing Specific Functions
- Using as to Give a Function an Alias
- Using as to Give a Module an Alias
- Importing All Functions in a Module
- Styling Functions
9. Classes
- Creating and Using a Class
- Creating the Dog Class
- Making an Instance from a Class
- Working with Classes and Instances
- The Car Class
- Setting a Default Value for an Attribute
- Modifying Attribute Values
- Inheritance
- The __init__() Method for a Child Class
- Inheritance in Python 2.7
- Defining Attributes and Methods for the Child Class
- Overriding Methods from the Parent Class
- Instances as Attributes
- Modeling Real-World Objects
- Importing Classes
- Importing a Single Class
- Storing Multiple Classes in a Modul
- Importing Multiple Classes from a Module
- Importing an Entire Module
- Importing All Classes from a Module
- Importing a Module into a Module
- Finding Your Own Workflow
- The Python Standard Library
- Styling Classes
Day Four10.11
10. Files and Exceptions
- Reading from a File
- Reading an Entire File
- File Paths
- Reading Line by Line
- Making a List of Lines from a File
- Working with a Files Contents
- Large Files: One Million Digits
- Is Your Birthday Contained in Pi?
- Writing to a File
- Writing to an Empty File
- Writing Multiple Lines
- Appending to a File
- Exceptions
- Handling the ZeroDivisionError Exception
- Using try-except Blocks
- Using Exceptions to Prevent Crashes
- The else Block
- Handling the FileNotFoundError Exception
- Analyzing Text
- Working with Multiple Files
- Failing Silently
- Deciding Which Errors to Report
- Storing Data
- Using json.dump() and .load()
- Saving and Reading User-Generated Data
- Refactoring
11. Testing Your Code
- Testing a Function
- Unit Tests and Test Cases
- A Passing Test
- A Failing Test
- Responding to a Failed Test
- Adding New Tests
- Testing a Class
- A Variety of Assert Methods
- A Class to Test
- Testing the AnonymousSurvey Class
- The setUp() Method
Day FiveVisualisation Project
1.Generating Data- Installing matplotlib
- On Linux
- On OS X
- On Windows
- Testing matplotlib
- The matplotlib Gallery
- Plotting a Simple Line Graph
- Changing the Label Type and Graph Thickness
- Correcting the Plot
- Plotting and Styling Individual Points with scatter()
- Plotting a Series of Points with scatter()
- Calculating Data Automatically
- Removing Outlines from Data Points
- Defining Custom Colors
- Using a Colormap
- Saving Your Plots Automatically
- Random Walks
- Creating the RandomWalk() Class
- Choosing Directions
- Plotting the Random Walk
- Generating Multiple Random Walks
- Styling the Walk
- Coloring the Points
- Plotting the Starting and Ending Points
- Cleaning Up the Axes
- Adding Plot Points
- Altering the Size to Fill the Screen
- Rolling Dice with Pygal
- Installing Pygal
- The Pygal Gallery
- Creating the Die Class
- Rolling the Die
- Analyzing the Results
- Making a Histogram
- Rolling Two Dice
- Rolling Dice of Different Sizes
2.Downloading Data- The CSV File Format
- Parsing the CSV File Headers
- Printing the Headers and Their Positions
- Extracting and Reading Data
- Plotting Data in a Temperature Chart
- The datetime Module
- Plotting Dates
- Plotting a Longer Timeframe
- Plotting a Second Data Series
- Shading an Area in the Chart
- Error-Checking
- Mapping Global Data Sets: JSON Format
- Downloading World Population Data
- Extracting Relevant Data
- Converting Strings into Numerical Values
- Obtaining Two-Digit Country Codes
- Building a World Map
- Plotting Numerical Data on a World Map
- Plotting a Complete Population Map
- Grouping Countries by Population
- Styling World Maps in Pygal
- Lightening the Color Theme
3.Working with APIs- Using a Web API
- Git and GitHub
- Requesting Data Using an API Call
- Installing Requests
- Processing an API Response
- Working with the Response Dictionary
- Summarizing the Top Repositories
- Monitoring API Rate Limits
- Visualizing Repositories Using Pygal
- Refining Pygal Charts
- Adding Custom Tooltips
- Plotting the Data
- Adding Clickable Links to Our Graph
- The Hacker News API
Subscribe to our Newsletter for latest news.
If the pdf download does not work, try a different browser
© 2004+Back to top