/Python-Fundamentals

D-Lab's 12 hour introduction to Python. Learn how to create variables and functions, use control flow structures, use libraries, import data, and more, using Python and Jupyter Notebooks.

Primary LanguageJupyter NotebookOtherNOASSERTION

D-Lab Python Fundamentals

This is the repository for D-Lab's introductory Python-Fundamentals workshop series. Laptop, Internet connection, and Zoom account required.

Workshop goals

There are four folders (one for each day) that contain the notebooks we will walk through for each day:

Day_1 - Running Python, Jupyter Notebooks, variables assignment, data type conversion, working with strings, built-in functions

Day_2 - Lists, for-loops, conditional statements, writing your own functions, scope

Day_3 - Dictionaries, reading and writing data from and to files, installing and importing libraries, debugging errors, list comprehensions, beautiful code

Day_4 - Python application for information retrieval. You will extract targeted information from a text data set of United Nations documents to generate tabular data in a .csv file suitable for subsequent statistical analysis. Everything needed for this exercise is covered in Days 1, 2, and 3.

Installation Instructions

Download and install Python Anaconda distribution 3.7 and the workshop materials to get started. Before Part 1 be sure to:

  1. Download and install Python Anaconda distrubtion 3.7 --> Click "Download" and then click 64-bit "Graphical Installer" for your current operating system.

  2. Download the Python-Fundamentals workshop materials. To run these lessons on your laptop:

  • Click the green "Clone or Download" button
  • Click "Download Zip"
  • Extract this file someplace familiar (we recommend Desktop)

Is Python not working on your laptop?

If you have a Berkeley CalNet ID, you can run these lessons on UC Berkeley's DataHub by clicking this link. By using this link, you can save your work and come back to it at any time. When you want to return to your saved work, just go straight to DataHub (https://datahub.berkeley.edu), sign in, and you click on the python-fundamentals folder.

If you don't have a Berkeley CalNet ID, you can still run these lessons in the cloud, by clicking this button: Binder By using this button, you cannot save your work unfortunately.

If you are a Git user, simply clone this repository by opening a terminal and typing: git clone git@github.com:dlab-berkeley/python-fundamentals.git

Run the code!

First, open the Anaconda Navigator application. You should see the green snake logo appear on your screen and this could take a few minutes to load up the first time. Then click the "Launch" button under "Jupyter Notebooks" and navigate through your file system to the "Python Fundamentals" folder you downloaded above. Then, open the "Day_1" folder and click 02_Jupyter Notebooks.ipynb to begin. Press Shift + Enter (or Ctrl + Enter) to run a cell.

How to get help?

  • Within the language/tool itself
  • Via Google searching
  • On stackoverflow

Resources

  • [Quintessential book and authors](link to website)
  • {Important website name](link to website)
  • et cetera

About the UC Berkeley D-Lab

D-Lab works with Berkeley faculty, research staff, and students to advance data-intensive social science and humanities research. Our goal at D-Lab is to provide practical training, staff support, resources, and space to enable you to use R for your own research applications. Our services cater to all skill levels and no programming, statistical, or computer science backgrounds are necessary. We offer these services in the form of workshops such as R Fundamentals, one-to-one consulting, and working groups that cover a variety of research topics, digital tools, and programming languages.

Visit the D-Lab homepage to learn more about us. View our calendar for upcoming events, and also learn about how to utilize our consulting and data services.

(include definition of IOKN2K!)

Other D-Lab Python Workshops

Check out the D-Lab Computational Text Analysis Working Group by clicking here

Basic competency

Intermediate/advanced copmetency

Legacy workshops (need updating)

Contributors

  • [Contributor A](link to D-Lab bio)
  • [Contributor B](link to D-Lab bio)
  • Much of the Python-Fundamentals materials were adapted from those produced by Software Carpentry. Thank you!