forked from SocialComplexityLab/socialgraphs2021
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
573ac77
commit 67ca5b0
Showing
1 changed file
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Introduction to Python & Jupyter Notebooks\n", | ||
"\n", | ||
"In this class, we will rely on Python as our main tool for data science. We will be running in Python in Jupyter Notebooks. Most of you are at home in Python, and will only have to spend a few moments here. I have planned for three scenarios\n", | ||
"\n", | ||
"1. **You don't know anything about Python, only have a bit of experience**. Then read this whole thing carefully and follow the advice in Part 3 carefully.\n", | ||
"2. **You have a bit of experience with Python, but feel like you need a refresher**. Then go through this notebook, chill a bit with the video, and make sure that you can do everything asked of you in the exercises at the end of Part 2. Then you're good to go.\n", | ||
"3. **You're a pretty good python user and used to working with Jupiter Notebooks**. Then safely skip the whole thing." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Part 1: Installing Python\n", | ||
"\n", | ||
"Now it's time to install Python. \n", | ||
"\n", | ||
"* We recommend you use the _Anaconda distribution_ of Python. You can download it [**here**](https://www.anaconda.com/distribution/).\n", | ||
"* Once Anaconda is installed, you start up the notebook system by typing `jupyter notebook` in your terminal, and the system should be ready to use in your favorite browser. \n", | ||
"* Be sure to check the keyboards shortcuts under the heading of \"Help\" where you will find for instance shortcut to code-completion (Tab) and tooltip with documentation (Shift-Tab) which will save you a ton of time. \n", | ||
"\n", | ||
"Part 3 will teach you how to use the Jupyter Notebook. Note that if you want to use another Python distribution, that's fine, but we cannot promise to help you with anything other than Anaconda. " | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Part 2: Simple Python exercises\n", | ||
"\n", | ||
"> **_Video lecture_**: If you'd like an intro to Jupyter Notebooks and iPython, there's one below. I talk a bit about why we use Python, demo MarkDown, and provide a few tips & tricks. If you already known Python and Jupyter Notebooks, this video lecture is safe to skip." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"image/jpeg": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2MBERISGBUYLxoaL2NCOEJjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY//AABEIAWgB4AMBIgACEQEDEQH/xAAbAAEAAgMBAQAAAAAAAAAAAAAAAQIDBAUGB//EADkQAQACAgEBBwMDAAgGAwEAAAABAgMRBBQFEhMhMVGRIkFSBjJhQnGBobHB0fAjMzVyc+EWNJMV/8QAFQEBAQAAAAAAAAAAAAAAAAAAAAH/xAAUEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwD5+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM/S396nS396gwDP0t/ep0t/eoMAz9Lf3qdLf3qDAM/S396nS396gwDP0t/eqOmv71BhGbpr+9Tp7+9QYRl6e/vU8C3vAMQy+Bb3hHgW94BjGTwbe8Hg294BjGTwbe8Hg294BjGTwbe8Hg294BjGTwbe8HgW94BjGXwLe8HT294BiGXp7+9Tp7+9QYhm6e/vU6e/vUGEZunv71R09/eoMQy+Bb3g8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www.youtube.com/embed/H9YrBVIcXS4\"\n", | ||
" frameborder=\"0\"\n", | ||
" allowfullscreen\n", | ||
" ></iframe>\n", | ||
" " | ||
], | ||
"text/plain": [ | ||
"<IPython.lib.display.YouTubeVideo at 0x1120671d0>" | ||
] | ||
}, | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"from IPython.display import YouTubeVideo\n", | ||
"YouTubeVideo(\"H9YrBVIcXS4\",width=600, height=337.5)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Video notes:\n", | ||
"\n", | ||
" * Scipy (https://www.scipy.org)\n", | ||
" * NetworkX Homepage (https://networkx.github.io)\n", | ||
" * XKCD (https://xkcd.com/353/). About trying Python for the first time.\n", | ||
" * Anaconda (https://www.anaconda.com/distribution/).\n", | ||
" * Markdown (https://daringfireball.net/projects/markdown/syntax and https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet)\n", | ||
" * Stack Overflow (Don't search stack overflow. Google your problem and the stack overflow is usually the right link)." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"> _Exercises_\n", | ||
"> \n", | ||
"> * Download the IPython file that I've prepared for you and save it somewhere where you can find it again. The link is [**here**](https://raw.githubusercontent.com/SocialComplexityLab/socialgraphs2021/main/files/Training_notebook.ipynb). (**Hint**: Be careful not to save this in _.txt_ format - make sure the extension is _.ipynb_.)\n", | ||
"> * Work through exercise 1-9 in the file, solving the simple Python exercises in there. Also use this as a chance to become familiar with how the IPython notebook works. (And a little bit of `json`). " | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Part 3: A warning\n", | ||
"\n", | ||
"### STOP: Super important notice\n", | ||
"\n", | ||
"Now that you've completed working through the IPython notebook, it's time for the moment of truth! If you had great difficulty with the Python coding itself, you're going to be in trouble. Everything we do going forward in this class will depend on you being comfortable with Python. There is simply **no way** that you will be able to do well, if you're also struggling with Python on top of everything else you'll be learning.\n", | ||
"\n", | ||
"**So if you're not 100% comfortable with Python, I recommend you stop right now, and follow a tutorial to teach you Python, for example [this one](https://www.learnpython.org), before proceeding**. This might seem tough, but the ability to program is a prerequisite for this class, and if you know how to program, you should be able to handle the Python questions above.`" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.7.7" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |