1. Start!
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.
3. Python
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!