<jupyter_start><jupyter_text>Introduction and overviewWelcome to [PSYC 132: Introduction to Programming for Psychological Scientists](https://github.com/ContextLab/cs-for-psych)!In this course we'll be using [Google Colaboratory](https://colab.research.google.com/) and [GitHub Classroom](https://classroom.github.com/) to learn how to:*   Write and understand computer programs written in Python*   Design and implement psychological experiments*   Carry out data analyses on real experimental data*   Build basic computational models of experimental data*   Generate compelling figures to display the results visually and help you understand what your data are telling youA full course syllabus is available [here](https://github.com/ContextLab/cs-for-psych/blob/master/admin/PSYC_132_syllabus.pdf).  Learning objectivesThis notebook is intended to teach you:1.   How to set up your Google Colaboratory and GitHub accounts2.   How to use Jupyter (Colaboratory) notebooks  How to set up your Google Colaboratory and GitHub accounts Google ColaboratoryGoogle Colaboratory is a system for writing and running code through a web browser.  Your files are stored on Google Drive, and code that you run is executed on a remote Google Cloud server.  To learn more about Google Colaboratory, check out [this document](https://colab.research.google.com/notebooks/welcome.ipynbscrollTo=xitplqMNk_Hc).Google Colaboratory (including access to Google Cloud computers) is included as part of all Google accounts.  To gain access to this resource, you first need to sign up for a Google account (if you don't already have one).  Remember your username (email address) and password; you'll use it throughout the term and you'll rely on Colaboratory for most of your slides.  You can sign up for a Google account [here](http://www.google.com/).  Once you've signed into your Google account, you can access Google Colaboratory [here](https://colab.research.google.com/). GitHubWe'll use GitHub to distribute and submit slides.  We'll learn more about Git and GitHub (soon!) as we progress in the course.  At a high level, Git is a tool for saving and tracking different versions of your files, and GitHub is a server (computer that you can access remotely via the web) that stores your files.  For now you'll just need to set up an account-- you don't yet need to know what you're doing on GitHub or why (although if you want to learn more you can check out [this quick-start tutorial](https://www.codecademy.com/learn/learn-git)).  I also put together a [YouTube playlist](https://www.youtube.com/playlist?list=PLjQYT8Fwp984zMjN5rJChfdI5Z8jtaWww) to provide some additional background (that playlist is part of my [Storytelling with Data](https://github.com/ContextLab/storytelling-with-data) course). For now, you just need to create a GitHub account and get yourself set up so that you are able to access and submit course assignments.  To create an account (if you don't already have one), go to [github.com](https://github.com/) and follow the "sign up" instructions.  Remember your username and password; you'll need it throughout the rest of the course.  How to use Jupyter (Colaboratory) notebooksThe document you're viewing right now is a Jupyter notebook.  A Jupyter notebook is a file (extension: .ipynb, which stands for "**i**nteractive **Py**thon **n**ote**b**ook).  The contents of Jupyter notebooks are stored as .json (JavaScript Object Notation) files.  It's not super important that you familiarize yourself with the nitty-gritties of the .json format at this point in the course, but we'll revisit it later when we start working with data. What's a Jupyter notebook?For a more complete answer, check out [this video](https://youtu.be/CSkTJRNBTME).  The short answer is that a Jupyter notebook is an interactive tool that allows you to take notes, execute code, create figures, and easily share it all with other people.  Jupyter notebooks comprise a series of _cells_.  Each cell (looks like a rectangular block of text) in a notebook contains one of two basic categories of content:  1. **Markdown cells** (like the current cell) contain formatted text in the [Markdown text formatting language](https://www.markdowntutorial.com/).  You can use these cells kind of like the code underlying text you'd write in a word processor.  What you type is what eventually appears on the screen.  For the most part, text in Markdown cells gets "rendered" (i.e. drawn on the screen) just as you write it.  However, you can also specify various formatting tweaks, like creating _italicized_ or **bolded** text, etc.  [This tutorial](https://www.markdowntutorial.com/) provides a quick and gentle interactive introduction to Markdown.  You can create a new Markdown cell by pressing the "+" button in the toolbar and selecting "Markdown" from the dropdown list in the toolbar.  2. **Code cells** (like the next cell) contains computer code. A computer is like a fancy calculator; computer code is a set of instructions that tells the computer which things to do (and in which order).  You can create a new Code cell by pressing the "+" button in the toolbar and selecting "Code" from the dropdown list in the toolbar.  The text you type into a new notebook cell is a set of instructions that tell the notebook what to do when the cell is _run_ (i.e., transformed from a set of instructions into an executed set of actions).  To run a cell, hold the `shift` key and press `enter/return`.  - When you run a Markdown cell, the text is rendered with the formatting options you specify.  To see and/or edit the underlying code, simply double click on the rendered text.  - When you run a Code cell, the Python instructions you type in are run.  We'll explore what this means below.  Note: the first time you run a Code cell, you'll see a warning message pop up (asking if it's OK to run code not authored by Google).  You should give the notebook permission to run so that you can interact with it.   Running Python code in Jupyter notebooksIf you're accessing this notebook within Google Colaboratory, you can interact with Code by running it on Google's computers (via Google Cloud-- i.e., Google's high performance computing cluster).  The first time you run a command within a colaboratory notebook, you'll automatically be allocated a virtual computer (i.e., a simulation of a computer that's running somewhere on Google's servers).  It takes a few seconds to boot that system up (you'll see a "connecting" message in the upper right when the new computer is being allocated, and you'll see a bar graph showing RAM and disk usage once the computer is ready).  This all happens automatically (there's nothing you need to "do" in order to set up one of these virtual computers, aside from view and interact with the notebook in Google Colaboratory). A small taste of PythonThe simplest way to think about Python is like a sort of calculator.  For example, you can type in an equation, and when you "run" that line of code the answer is printed to the console window.  Play around with the examples below to explore (double click on code to edit it, and press `shift` + `return` to run it.<jupyter_code>1 + 1
3 * (4 + 1)<jupyter_output><empty_output><jupyter_text>You can also do fancier stuff in Python, like generating plots.  Whereas basic math functions (addition, subtraction, multiplication, division, etc.) are included in the [Python standard library](https://docs.python.org/3/library/) (i.e., the base set of instructions that the Python language is built on), generating graphics and figures will require you to use additional [libraries](https://en.wikipedia.org/wiki/Python_(programming_language)Libraries) (you can gain access to them using `import` statements).  We'll learn more about this later.<jupyter_code>from matplotlib import pyplot as plt
import numpy as np

x = np.arange(0, 2*np.math.pi, 0.1)
plt.plot(x, np.sin(x))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.06345815531540588, 'fraction_numerical': 0.0033928122643880373, 'mean_word_length': 4.632696390658174, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 15, 'lorem ipsum': 0, 'www.': 5, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '207521', 'license': 'MIT', 'n_tokens_mistral': 2088, 'n_tokens_neox': 1977, 'n_words': 1156, 'path': 'Copy_of_Copy_of_introduction_and_overview.ipynb', 'repo_name': 'franklee20/cs-for-psych', 'size': '7958'}