官术网_书友最值得收藏!

Python basics - Part 1

If you already know Python, you can probably skip the next two sections. However, if you need a refresher, or if you haven't done Python before, you'll want to go through these. There are a few quirky things about the Python scripting language that you need to know, so let's dive in and just jump into the pool and learn some Python by writing some actual code.

Like I said before, in the requirements for this book, you should have some sort of programming background to be successful in this book. You've coded in some sort of language, even if it's a scripting language, JavaScript, I don't care whether it is C++, Java, or something, but if you're new to Python, I'm going to give you a little bit of a crash course here. I'm just going to dive right in and go right into some examples in this section.

There are a few quirks about Python that are a little bit different than other languages you might have seen; so I just want to walk through what's different about Python from other scripting languages you may have worked with, and the best way to do that is by looking at some real examples. Let's dive right in and look at some Python code:


If you open up the DataScience folder for this class, which you downloaded earlier in the earlier section, you should find a Python101.ipynb file; go ahead and double-click on that. It should open right up in Canopy if you have everything installed properly, and it should look a little bit something like the following screenshot:

New versions of Canopy will open the code in your web browser, not the Canopy editor! This is okay!

One cool thing about Python is that there are several ways to run code with Python. You can run it as a script, like you would with a normal programming language. You can also write in this thing called the IPython Notebook, which is what we're using here. So it's this format where you actually have a web browser-like view where you can actually write little notations and notes to yourself in HTML markup stuff, and you can also embed actual code that really runs using the Python interpreter.

主站蜘蛛池模板: 惠安县| 荣昌县| 台州市| 吉隆县| 永和县| 乌拉特后旗| 宣城市| 洞头县| 库伦旗| 舟曲县| 东乡族自治县| 武隆县| 三江| 宜阳县| 朝阳区| 闸北区| 仪征市| 长子县| 招远市| 格尔木市| 连平县| 澄城县| 克拉玛依市| 会昌县| 文昌市| 正宁县| 临泉县| 田林县| 阜城县| 隆安县| 连云港市| 永顺县| 来宾市| 阳山县| 白山市| 龙南县| 榆树市| 太康县| 应城市| 宝丰县| 石楼县|