Hi, my name is Hugo and I’ll be your host for Introduction to Python for Data Science. I’m a data scientist and educator at DataCamp and host of the DataFramed podcast, which you must check out.
2. How you will learn
In this course, you will learn Python for Data Science through video lessons, like this one, and interactive exercises. You get your own Python session where you can experiment and try to come up with the correct code to solve the instructions. You’re learning by doing, while receiving customized and instant feedback on your work.
Python was conceived by Guido Van Rossum. Here, you can see a photo of me with Guido. What started as a hobby project, soon became a general purpose programming language: nowadays, you can use Python to build practically any piece of software. But how did this happen? Well, first of all, Python is open source. It’s free to use. Second, it’s very easy to build packages in Python, which is code that you can share with other people to solve specific problems. Throughout time, more and more of these packages specifically built for data science have been developed. Suppose you want to make some fancy visualizations of your company’s sales. There’s a package for that. Or what about connecting to a database to analyze sensor measurements?
There’s also a package for that. People often refer to Python as the swiss army knife of programming languages as you can do almost anything with it. In this course, we’ll start to build up your data science coding skills bit by bit, so make sure to stick around to see how powerful the language can be.
Currently, there are two common versions of Python, version 2-point-7 and 3-point-5 and later. Apart from some syntactical differences, they are pretty similar, but as support for version 2 will fade over time, our courses focus on Python 3. To install Python 3 on your own system, follow the steps at this URL.
4. IPython Shell
Now that you’re all eyes and ears for Python, let’s start experimenting. I’ll start with the Python shell, a place where you can type Python code and immediately see the results. In DataCamp’s exercise interface, this shell is embedded here. Let’s start off simple and use Python as a calculator.
Let me type 4 + 5, and hit Enter. Python interprets what you typed and prints the result of your calculation, 9. The Python shell that’s used here is actually not the original one; we’re using IPython, short for Interactive Python, which is some kind of juiced up version of regular Python that’ll be useful later on.
IPython was created by Fernando Pérez and is part of the broader Jupyter ecosystem. Apart from interactively working with Python, you can also have Python run so called
7. Python Script
python scripts. These python scripts are simply text files with the extension (dot) py. It’s basically a list of Python commands that are executed, almost as if you where typing the commands in the shell yourself, line by line.
Let’s put the command from before in a script now, which can be found here in DataCamp’s interface. The next step is executing the script, by clicking ‘Submit Answer’. If you execute this script in the DataCamp interface, there’s nothing in the output pane. That’s because you have to explicitly use print inside scripts if you want to generate output during execution.
Let’s wrap our previous calculation in a print call, and rerun the script. This time, the same output as before is generated, great! Putting your code in Python scripts instead of manually retyping every step interactively will help you to keep structure and avoid retyping everything over and over again if you want to make a change; you simply make the change in the script, and rerun the entire thing.
10. DataCamp Interface
Now that you’ve got an idea about different ways of working with Python, I suggest you head over to the exercises. Use the IPython Shell for experimentation, and use the Python script editor to code the actual answer. If you click Submit Answer, your script will be executed and checked for correctness.
11. Let’s practice!
Get coding and don’t forget to have fun!