- Live session will take place on June 16, 2021.
- Milena Tsvetkova, Assistant Professor of Computational Social Science, Department of Methodology, LSE
- Yuanmo He (GTA), PhD student in Social Research Methodology, Department of Methodology, LSE
This workshop introduces students to the fundamentals of computer programming in Python. The workshop is intended for students who lack a formal background in the field. Topics include data types, control structures, functions, and an introduction to the principles of object-oriented programming. We will learn to design and write simple computer programs, using a practical example from computational social science.
This is an introductory workshop and no prior experience with programming or Python is required.
The workshop will use Jupyter Notebooks to edit and write code. Students have two options:
-
Use Google Colab to work in the cloud via your web browser.
- You will need a Google account to use Colab so if you don't already have one, create it. Other than that, you do not need to install any specialized software.
- Open the Colab file in your browser by first clicking on the link and then on
Open with Google Colaboratory
on top of the page. - Click on
Copy to Drive
to create your own copy, which you can edit and save.
-
Alternatively, you can pre-install Python and Jupyter Notebooks locally on your personal computer and run them from there. Unfortunately, we will be unable to provide support for this option, so choose it only if you already have some experience with the software.
- Install Anaconda, which comes with both, as well as with the most common data science packages.
- Clone/download this repository on your computer.
- Run the Jupyter server and open the file
python_intro.ipynb
from the cloned repository.
All materials for the workshop are available at https://github.com/social-research/python-workshop.
Additional optional resources include:
- RESOUCES.md file
- Python Wikibook
- Matthes, Eric. Python Crash Course Cheat Sheet.
- Intermediate and advanced Python documentation
- Introduction to programming languages
- Introduction to Jupyter Notebooks/Google Colab
- Markup vs. programming languages
- Primitives in Python
- Scalar data types, operators, expressions, and value assignment to variables
- Non-scalar data types:
str
,list
,tuple
,set
, anddict
- Sequence operations and methods, aliasing vs. cloning
- Control flow in Python
- Branching with
if
,elif
, andelse
- Iteration with
while
andfor
range()
and list comprehensions
- Functions in Python
- Function arguments and variable scope
- Modules
- Data abstraction with objects and classes