Meet your instructor Mattan Griffel and get a quick overview of the structure of the course. In this first lesson, you’ll meet your instructor and get an answer that is probably on your mind: Can you learn how to code in a month? Mattan will give you a brief history of the course, give you a quick overview of what you will learn as well as make some recommendations on how to go through the material to ensure that you indeed are able to create useful applications after a month of Python lessons.
Python is a general-purpose programming language that has wide application in various fields. In this lesson, we look at some areas in which Python is used, for example in web development, desktop app development, data science, building Internet of Things, creating distributed systems, etc. What can you do with Python? There are many, many cool things! We take a look, as well as cover what you will learn in this course.
You might be wondering: How and why should I start learning Python? To help you answer that, we’ll look at various programming languages and compare a few popular ones with Python. You'll find out why Python is a useful tool to have under your belt whether you are learning your first language or looking to learn an additional one. You’ll find out why Python is especially a good language to learn for first-time developers.
We look at the history of Python and explore the differences between Python 2 and Python 3. For the course, we use (and recommend) Python 3. Python 2 is legacy, Python 3 is the future and so we recommend learning the latter. The two versions share similarities, so if you learn Python 3, you will still be able to read and understand any legacy Python 2 code you might come upon.
Before you can start coding with Python, you have to ensure that your machine is set up right. We'll take you through the process of installing Python on your MacOS, Windows or Linux OS via the Anaconda distribution. After that, you'll need to install a code editor. We use Sublime Text 3, but you can use any editor you prefer like Visual Studio Code, Atom, PyCharm, etc.
We take a sanity check to verify that you set up your development environment right. You'll test your Python installation and ensure that you have the right version of Python installed—version 3.0 or later.
In this lesson, you'll be introduced to the Command Line, aka the Terminal. We'll show you how to customize your Terminal and then we'll take you through some example Bash commands that you can execute on the Command Line. The Command Line will be used to manage your Python projects and run your Python Code. The commands you learn here will be used throughout the course.
Let's run your first Python script! In this lesson you'll learn how to navigate the file system with the command line as well as how to run Python scripts. If you browse Github for "Python scripts" you'd see that there are so many useful Python scripts (available for free!), but before you dive in too deep we need to start with the basics: your first Python script!
We go through the Python code that you just ran in the last lesson line by line to understand what it does. You'll be introduced to Python syntax, how to store data in variables as well as how to print out information to the screen.
The best way to learn to code is by coding. In this lesson, you will dive into your first programming challenge. You'll be given instructions to modify the previous Python script. Don't be scared, just dive in! In the next less, we’ll review the solution (no peeking just yet).
You've just completed your first coding challenge. Cheers to you! In this lesson, Mattan walks you through the solution to the challenge. He shows you how to add data to a Python List, change the output of printed information and points out some syntax errors that you can run into—giving you a brief introduction to debugging, which will be covered in more depth in later lessons.
Here, you get to try out your coding chops again with another challenge. We promised you a very hands-on practical coding course, so expect many of these challenges along the way. You'll build a randomizer script that outputs a string based on some randomly picked options. Feel free to share your masterpiece with the community on Slack.
There are two ways in which you can run Python code—by executing a script file with the python command, or by executing commands in the Interactive Shell. You have already done the former. In this lesson, you will be introduced to the Interactive Shell. You will learn how to launch it and use it to execute Python code.
At some point during your programming journey, you will have to write code that outputs some information. In Python, this is done with the print function which is a built-in function. In this lesson, you will learn how to write code that prints data to the screen. Printing information is useful not just for communicating with users of the program, but it can also come in handy when you are debugging code. Watch and I'll share a few Python print examples, and then you can create print functions and arguments from scratch.
No developer writes perfect code all the time. One thing you should expect is that your code won't always work as expected. An important part of programming is testing and debugging. This lesson will show you how to read error messages that are output to the Terminal and how to identify the code that caused the error. Debugging is something we'll be using throughout the course, so by the time you complete it, you'll be quite adept at finding and fixing bugs in your code. In this leson, I'll also show you how to get the most out of debugging with Google and StackOverflow.
Other than writing bug-free code, you should also strive to write code that is easily readable and understandable. Programming languages allow developers to add annotations (i.e. comments) to the source code of their programs that help explain what the code is doing, making it easier for anyone reading the code to understand it.
Variables are used to label and store data that can be referenced and manipulated by your code. You have already worked with variables in the code you've written so far. This lesson will dive deeper into variables. You'll learn the rules governing the naming of variables as well as some recommended industry conventions to follow.
One thing computers are great at is performing computations. In this lesson, we'll do some Math using Python. You'll learn how to use the common arithmetic operators (e.g. Addition, Subtraction, Multiplication, Division and Modulus) as well as the rules governing the order in which they are executed.
In programming, a string is a sequence of characters. They are usually used to store data in text form. Here, we explore the string format in Python. We see how to create them as well as how to deal with strings that contain special characters through what is referred to as Escaping. I'll also introduce you to Kanye West's "greatest pain" — the one thing in life that both you and I have access to, but that he never will. And no, it's not our mortality.
Sometimes, you usually need to combine the values of two or more variables. This is done through string interpolation which is the process of evaluating a string literal containing one or more placeholders, yielding a result in which the placeholders are replaced with their corresponding values. How do you put a variable inside a string? Let me show you how!
At some point in your programming career, you will write software that takes input from the user and processes it. This lesson covers how to do this. You will learn how to read and utilize user input. User input usually comes in the form of strings. Sometimes this isn't what your code needs and so we will show you how to cast this into an appropriate type.
As mentioned, you will do a lot of debugging in this course. This is a crucial skill in every developer's toolset. By the time you are done with the course, you will have the skills to test and debug all sorts of code. In this lesson, help Matan track down a bug that he has encountered. We look at how to identify relevant Error messages as well as how to use the internet for further investigation on the error.
Having covered various topics (variables, strings, arithmetic operators, debugging, type casting, etc.), you will now put this knowledge to use in an assignment. Feel free to ask for help from other community members and to even collaborate through pair programming.
Week 2 starts off with Mattan showing you a couple of possible solutions to last week’s assignment. In programming, there is usually more than one way of solving a problem, so if your solution looks a little different, don't worry about it being wrong. If you get the expected results, then it is most likely a correct solution. Watch on to find out other ways you could have solved it!
Sometimes you will need your program to make a decision between one or more conditions to determine what code should be run. This is done by using conditional statements. With conditional statements, you can specify a set of conditions (often referred to as "if then" statements) that will decide "if" certain code should be run or not.
One unique thing about Python is its use of whitespace as part of its syntax. Most programming languages use braces to denote blocks of code, but in Python you use whitespace. You use leading whitespace (tabs or spaces) at the beginning a line to denote the indentation level of the statements. Watch this video and learn more!
In this lesson, we expand our knowledge of Python conditional statements by looking at ways of checking for more than one condition by using the if...else, if...elif...else and nested if conditional statements.
In this lesson, we look at Python logical operators. Them most popular ones you need to know are: and, or , not, ==, !=, >, and <. You'll also learn how to determine if a value is either True or False.
Time to put your newfound knowledge of Python logical operators to the test. In this lesson, you will download a .py (Python) file containing a list of conditional tests that evaluate to either True or False. Test your understanding of Python logic by putting down the expected Boolean result of each expression.
Did you work through the last challenge? If you didn't, we recommend you go back and work through it before proceeding. Practicing is the best way to learn coding (or anything else). If you worked through the challenge, watch this lesson for the solutions to each of the problems and see how well you fared.
In this lesson, we introduce the Or logical operator. This operator returns True if at least one of the expressions it's evaluating return True, otherwise, it returns False. You will learn some rules regarding the order in which it evaluates expressions—knowing this could save you from some logical bugs in your code.
If you have several values and want to evaluate if a certain value is equal to any of the available values, you can either string together several comparison expressions with OR statements, or even better, you can place the values in a Python sequence—for instance, a list—and use the IN operator to check if your data is in the list. This makes the code succinct and more readable.
In programming, there is always more than one way to solve a problem. However, you will find that some solutions are usually better than others. Whenever you write code, there is usually a way that code can be improved either for improved readability, better performance, or best practices. Two rules of thumb to remember when refactoring your code are: Keep it Simple and Don't Repeat Yourself.
There are four built-in data structures in Python—list, tuple, dictionary, and set. In this lesson, we look at Lists. A List is a collection that is ordered, mutable (i.e. changeable) and allows duplicate members. It can hold values of any type e.g. numbers, strings, boolean values, and other data structures, for instance, another list.
In this lesson, Mattan will show you how to loop over the elements in a List. This might come in handy in situations where you need to perform certain operations on each item in a List.
At the end of the last lesson, Mattan left you a small challenge which he'll solve in the next video. For another challenge, try to search online on how to use the following—insert(), pop(), clear() and del—which provide other ways in which lists can be changed.
Mattan starts off solving the challenge from the last lesson. He then refactors the code and improves it by using a Range instead of a List. In Python, a Range will give you a sequence of numbers that are between two provided values: a lower limit and an upper limit. The sequence starts at the lower limit and goes up to, but doesn't include the upper limit.
Here, we look at ways we can access List items as well as ways we can get other useful information about a List and its items. You will find out how to access individual items inside a list using an index (sequentially as well as in reverse order), how to find the length of a list (i.e. the number of items in the list), and how to check for the data type of a list item.
Challenge time! You are going to use what you've learned so far to solve the famous FizzBuzz Coding Challenge. The challenge is common in Junior Developer job interviews and is used as a way to weed out job candidates who can't actually program, so give it a good attempt, you might actually encounter it if your goal at the end of the course is to get a developer job.
Hopefully, you gave the FizzBuzz challenge a try. Whether you got the solution or not, watch Mattan work through it, breaking it down to small manageable steps which he walks you through solving.
In this lesson, we look at another of Python's data structures: the Dictionary. It is an unordered, changeable and indexed collection that doesn't allow for duplicate members. It is similar to a list, in that it is a collection of objects, but the main difference between the two is that a List is ordered while a Dictionary isn't. Elements in a dictionary are saved in key-value pairs and are accessed using their key.
It is quite common to have dictionaries that contain values that are lists or to have lists that contain dictionaries. Sounds complicated, but Mattan will break down things for you and show you how to work with such data. He'll show you how to iterate and access the values in such objects as well as show you how best to avoid errors when doing so.
A function is a named group of code that performs some task. Functions are a core concept in just about any programming language. They are the most basic building blocks of programming and almost every task that a program runs happens inside a function. You can get away with building simple programs without the use of functions, but you will find that for most of your programming needs, it will make sense (and will generally be a good programming practice) to divide your logic into functions. This makes your code more readable, reusable and easily maintainable.
Let's learn more about Python functions! In this tutorial you will learn how to write a function definition as well as what characters and symbols can be used in a function identifier. You will also learn more about function arguments, and the concept of scope in Python.
Time for another challenge! Mattan lays out some instructions for a program you should write. It tests the knowledge you've gained so far regarding functions. Good luck!
Hopefully, you tackled the last challenge. Watch on for the solution that Mattan came up with. He breaks the problem down into small manageable bits and explains how to solve each one.
We complete the week by leaving you some reading material and a challenge that is a bit tougher than what you've done so far. You'll download a code file that is buggy. Your task is to do some debugging and fix the code so that it outputs the expected results. Give it a try, it's not too tough—what you need to know to complete it has been covered in the course so far, so feel free to rewatch some lessons if you need to. And finally, congrats! You've made it halfway through the course :)
We had a lesson where we used the Google Finance API, which has now been shut down. We removed the lesson, so you can quickly move forward to the second lesson of the week. You'll hear mention of the "Google Finance API" a few times in upcoming videos. Don't worry about this, you won't need to have used the API to follow along with what Mattan is talking about.
In your coding journey, a common task that you will perform with your code is accessing APIs (Application Programming Interface). APIs provide a way for two applications to communicate with each other. You will most often use APIs to access some data or to integrate an application with your own. In this lesson, you get your first taste of using APIs. We use the Dark Sky API to access weather forecast information. The lesson also introduces you to the use of third-party libraries that give you some pre-written code that saves you time having to write code from scratch while also simplifying things for you.
To continue our exploration of the use of APIs and third-party libraries, Mattan improves the previous Weather app by making use of a Geocoding library: GeoPy. The library makes it easy for Python developers to locate the coordinates of addresses, cities, countries, and landmarks across the globe using third-party geocoders and other data sources. We end the lesson with a little challenge for you.
Mattan starts off by solving the challenge given in the last lesson, then proceeds to give you another challenge. If you get stuck, be sure to read the documentation for the Dark Sky API as well as for the GeoPy library. Reading documentation is something you have to get comfortable with as a developer.
Did you solve the last challenge? We hope you did. Watch on as Mattan solves the challenge from the last lesson.
In this lesson, you'll get more experience using APIs by making use of the Twilio REST API. This API enables you to add messaging, voice, and video to your web and mobile application. We'll use it to build an application that sends SMS messages to a provided number. For easier access to the API, we'll use the twilio-python library which is a module for using the Twilio REST API and generating valid TwiML (Twilio Markup Language). At the end of the lesson, Mattan will give you another challenge.
Watch Mattan go through how he would solve the last challenge. If you want to learn more about the Twilio API (or any API and library we use in the course), the best place to look is its documentation. You should make yourself very comfortable with reading Documentation. This is a skill that you'll be using throughout your coding career.
APIs are a great way of getting data from another application to use in your own. Sometimes though, you'll come across a website that has some data that you would like to use but doesn't have a publicly available API. In such cases, web scraping can prove useful. Web scraping is simply the process of grabbing the content of a website and parsing it for useful data. In this lesson, we'll make use of the popular web scraping library Beautiful
In this lesson, we up the game and have a go at scraping a more difficult website: Amazon. Mattan will show you how to use the browser Developer Tools to figure out which data to filter for when scraping a website and he will also show you how to get past a website's bot filter.
In this lesson, we further improve the Amazon scraper we built in the last lesson. We are only interested in the product titles and prices, so we'll use Beautiful Soup to further narrow down the results from the last lesson to get this specific information. To be able to do this, we first need to know how the information is structured on the web page and so Mattan uses the browser Developer Tools to figure this out.
In this lesson, Chris Castig (Dean of One Month) will take a deep dive into the Beautiful Soup Documentation. He'll show you other features that the library has to offer and will give you some tips on how to read Documentation and how to find the information you need from software Documentation.
Time for another major Assignment! Mattan will give you an assignment for a program that you will write and submit for review. It will test the API knowledge you've gained in Week 3 as well as the Python basics that you learned from previous weeks.
If you're working through the course on a Windows machine, you might have encountered a UnicodeEncodeErrors error message when running your web scraper. Sometimes scrapers give you a UnicodeEncode error when Python encounters characters that it doesn't understand. Mattan shows you a fix that will get you past this bug.
You got to week 4! Time to learn flask. You are in the endgame now. In week 4, you'll get to use Python for two common use cases: building a web application and analyzing data. We start off the week by using the Flask framework to build a full-stack web application. The next few lessons will take you through the process of building out its backend and frontend. So let's get started with an introduction to Flask in Python.
To generate output in a Python web application, you use templates which are processed by a Template Engine to produce one or more desired output formats, commonly HTML, XML or PDF. In this lesson, we create a template file that will eventually be an HTML file on the launched web app. We use the Jinja2 Template Engine which is the default template engine used by Flask applications. Other Python Template Engines are Genshi, Mako, Chameleon, Diazo, Juno, Django template language (DTL), etc.
To improve the design of our web app, we use the Bootstrap CSS framework to style our webpage. You can style your web app from scratch or use an available CSS framework to help you along and save time. Other popular CSS frameworks that you can check out are Zurb Foundation, Materialize, Semantic UI, etc.
It's great that we have a running app and we are able to access it on the browser. However, we aren't really using the true power of Flask. We've created a template that only outputs static content. When building web applications, this will rarely be the case. Web applications usually need to run some code and process some data before displaying the resulting output to the user. In this lesson, we'll make our page dynamic by adding a bit of Python into the template.
In this lesson, we use what we learned about consuming APIs in our web application. We create a new page that displays Apple's stock price that has been grabbed from a public API.
Having an app that shows us Apple's stock price is great, but we can improve it further. It would be great if it could show us the price of any company stock we want. In this lesson, we do exactly that. We modify the app so that it takes user input and outputs stock information of the company the user specified.
If you've worked through the lessons and built the web application, you now have enough knowledge to build simple to fairly complex web apps. You should test your knowledge by coming up with web app ideas to build. Try cloning some of the applications you use. You don't have to implement all the features of the app, you can start with a simplified version and build up from there. If you get stuck, you can always consult the documentation of the technology you're using or ask for help in the community.
This lesson kicks off the Data Analysis section of the course. Python is widely used in such fields as Data Science and Machine Learning. This is one of the reasons it is so popular. We're going to be doing our data analysis work with a program called Jupyter Notebook. It comes with the Python installer, so you should already have it installed.
We do a little bit more exploring with Jupyter Notebook. Jupyter Notebook enables you to run Python code inside of a notebook. You can also visually represent what you're doing and share it with others.
To analyze data, we are going to need to learn pandas —an open source Python Data Analysis Library. In this pandas tutorial, we'll import data, and then you'll learn Python best-practices for parsing and structuring data.
Let's learn more about pandas! Now that we have some data loaded up, let's explore it with the pandas library. pandas provides some useful functions that you can use to get some information about your dataset or that you can use to filter the data. For instance head(n) returns the first n rows, tail(n) returns the last n rows, info() prints information about the data (like its memory usage, the types of each column, the number of values in the dataset), etc.
Pandas enables you to export data to a file. You can configure how you want the data saved by specifying such settings as the file name, file type (e.g. .csv or .txt), separators (CSV files use commas), etc.
Let's learn how to sort our data. For this, you use the data.sort_values(by='') function. Whatever is between the quotes represents the column to work with. You can also specify the order you want the sorted data in by passing the function an ascending argument (e.g. ascending=False or ascending=True).
So far, we've been using a data structure from the Pandas library called a DataFrame. According to the documentation, a DataFrame is a two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns). In simpler words, DataFrames are the tables we see when pandas runs our data. Underneath, a DataFrame is just a Python dictionary with lists inside of it. We look at how to create a DataFrame from scratch.
When analyzing a data set, you might want to only deal with some portion of the data set. With Pandas, you can easily grab a subset of a set of data. You can, for instance, specify that you want a certain column (or a few columns) and you can even use some functions on the subset to get specific information about the subset, e.g. using max() to get the maximum value in a subset, or mean() to get the average of all values in a subset.
Once we've evaluated our data, it can be useful to plot it and have it in a more visual form. In this lesson, we use the Matplotlib library to do this. Matplotlib is a Python 2D plotting library which produces figures in a variety of formats. With Matplotlib, you can easily generate plots, histograms, boxplots, power spectra, bar charts, pie charts, error charts, scatterplots, etc.
Let's look at another plotting library—Seaborn. Seaborn is a Python data visualization library based on matplotlib. It provides a high-level interface for drawing attractive and informative statistical graphics.
Now that we've visualized our data, we dig into an ordinary least squares (or OLS) regression. We use the StatsModels library to calculate this. StatsModels provides classes and functions for the estimation of many different statistical models, as well as for conducting statistical tests, and statistical data exploration.
In this lesson, we go over even more data selection! We look at various ways to get more specific with the data we are working with.
Pandas can also be used to group things together in ways that make the data more understandable. After grouping the data according to some criteria, Pandas makes available functions that you can use on the grouping to get specific information on it, e.g min() to get the minimum value in the group or mean() to get the group average.
Here, Mattan gives you a few challenges that will test your data analysis skills.
Mattan reveals how he would answer the previous data analysis challenge questions.
Data cleaning is a big part of data analysis. In order to run a proper analysis, you have to ensure that your data is clean and free of errors. When you get a data set that has some faults, you first have to clean it before using it. Data cleaning is the process of detecting and correcting (or removing) corrupt or inaccurate records from a data set. It usually involves identifying incomplete, incorrect, inaccurate or irrelevant parts of the data and then replacing, modifying, or deleting the dirty or coarse data.
A quick shoutout to data.gov. If you are looking for data sets that you can use in your projects, then check them out. They have a wide variety of cool data sets that you can explore.
The end is here! Congratulations on finishing Learn Python at One Month! It has been quite a journey. Your own journey shouldn't end here though. You should continue learning and practicing. Build stuff, attend meetups, go to hackathons, find members in the community to collaborate with, get comfortable with reading documentation and Stack Overflow, contribute to Open Source, etc. Here's to your continuous improvement.