{ "cells": [ { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "# Tools\n", "\n", "- Python\n", "- datahub\n", "- Jupyter Notebooks\n", "- Anaconda\n", "- Academic Integrity" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "skip" } }, "source": [ "This notebook will guide through the tools you will need for class materials and assignments, and how to get them. " ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "#### Question #1\n", "\n", "**How excited are you for COGS 18?**\n", "\n", "- A. Super excited! \n", "- B. The most excited! \n", "- C. Couldn't be more excited! \n", "- D. I love the smell of programming in the morning! " ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "### Prerequisites\n", "\n", "This course and associated materials do not presume any prior knowledge of Python, or programming in general. \n", "\n", "To work with the course materials, you will need make sure you have access to the tools tools described here on datahub. \n", "\n", "It will be helpful for the final project if they are also installed on the computer you will be using. \n", "\n", "None of the materials are computationally heavy. " ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "### What do you need?\n", "\n", "- **Required**: Access to datahub \n", " - Python (datahub uses python v3.9)\n", " - Jupyter Notebooks\n" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "<center><img src=\"img/python.png\" width=\"450px\"></center>" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ "<div class=\"alert alert-success\">\n", "Python is a programming language, whose development is led by the Python Software Foundation (PSF). \n", "</div>\n", "\n", "<div class=\"alert alert-info\">\n", "The official Python organization website is available <a href=\"https://www.python.org\" class=\"alert-link\">here</a>.\n", "</div>" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## Python\n", "\n", "- Versions: there are different versions of Python.\n", " - We will be using 3.9 on datahub (>3.6 required)\n", "- Packages: Python includes a \"base set\" of code (the standard library), and an extensive ecosystem of third party packages\n", " - In this course, we will largely focus on the standard library\n", " - For access to other packages when we need them, we will use Anaconda" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "<center><img src=\"img/jupyter.png\" width=\"300px\"></center>" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ "<div class=\"alert alert-success\">\n", "Jupyter notebooks are a way to intermix code, outputs and plain text. \n", "They run in a web browser, and connect to a kernel to be able to execute code. \n", "</div>\n", "\n", "<div class=\"alert alert-info\">\n", "The official Jupyter website is available \n", "<a href=\"http://jupyter.org\" class=\"alert-link\">here</a>.\n", "</div>" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## JupyterHub\n", "\n", "<div class=\"alert alert-success\">\n", "JupyterHub allows Jupyter notebooks to be shared across multiple users.\n", "</div>\n", "\n", "<div class=\"alert alert-info\">\n", "The official JupyterHub website is available \n", "<a href=\"https://jupyterhub.readthedocs.io/en/stable/\" class=\"alert-link\">here</a>.\n", "</div>\n" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "### Datahub\n", "\n", "UCSD hosts its version of JupyterHub and calls it datahub. This is what you'll be using in class.\n", "\n", "It is available here: http://datahub.ucsd.edu" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "-" } }, "source": [ "<center><img src=\"img/datahub.png\" width=\"800px\"></center>" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "### When to use Datahub?\n", "\n", "- Course Lecture Slides\n", "- CodingLabs\n", "- Assignments\n", "- Final Project/Exam" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "#### Lecture Slides:\n", "\n", "Once you've logged into datahub, click on the the following link: https://datahub.ucsd.edu/hub/user-redirect/git-pull?repo=https%3A%2F%2Fgithub.com%2FCOGS18%2FLectureNotes-COGS18&urlpath=tree%2FLectureNotes-COGS18%2F&branch=main\n", "\n", "(This link is also on the Canvas home page.)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "#### CodingLabs & Assignments:\n", "- Fetch & complete on datahub\n", "- do not change file names\n", "- do not copy cells provided\n", "- adding cells *is* allowed!\n", "- `print()` statements encouraged" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ "- For Submission:\n", " - Before you click submit, make sure it's the thing you want to submit\n", " - You ***must click submit***.\n", "\n", " - Always check that the CodingLab/Assignment/Exam shows up under \"submitted assignments\"\n", " - You can submit as many times as you want\n", " - We only have access to your most recent submission\n", " - If you submit past the deadline, we will only have access to your late submission" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "### A note about: Timezones\n", "\n", "- Due Dates are in UTC\n", "- All deadlines are 11:59 PM PST/PDT\n", "\n", "\n", "\n", "TimeZones: https://www.timeanddate.com/time/map/" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## Jupyter Notebooks\n", "\n", "- Markdown\n", "- code cells" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "<div class=\"alert alert-success\">\n", "Jupyter notebooks are a way to combine executable code, code outputs, and text into one connected file.\n", "</div>\n", "\n", "<div class=\"alert alert-info\">\n", "The official documentation from project Jupyter is available \n", "<a href=\"https://jupyter-notebook.readthedocs.io/en/stable/\" class=\"alert-link\">here</a>\n", "and they also have some example notebooks \n", "<a href=\"https://github.com/jupyter/notebook/tree/master/docs/source/examples/Notebook\" class=\"alert-link\">here</a>\n", ".\n", "</div>" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "skip" } }, "source": [ "<div class=\"alert alert-info\">\n", "For more useful information, check out Jupyter Notebooks \n", "<a href=\"https://www.dataquest.io/blog/jupyter-notebook-tips-tricks-shortcuts/\" class=\"alert-link\">tips & tricks</a>\n", ", and more information on how \n", "<a href=\"http://jupyter.readthedocs.io/en/latest/architecture/how_jupyter_ipython_work.html\" class=\"alert-link\">notebooks work</a>.\n", "</div>" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "### Menu Options & Shortcuts\n", "\n", "To get a quick tour of the Jupyter user-interface, click on the 'Help' menu, then click 'User Interface Tour'.\n", "\n", "There are also a large number of useful keyboard shortcuts. Click on the 'Help' menu, and then 'Keyboard Shortcuts' to see a list. " ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "### Cells" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ "<div class=\"alert alert-success\">\n", " The main organizational structure of the notebook are <b>cells</b>.\n", "</div>" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ "Cells are an independent 'unit'. When you click into a cell, you can 'run' it by clicking Shift + Enter, or by pressing the play (Run) button above. \n", "\n", "Cells come in different types for writing different things - mainly, text or code. " ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "#### Markdown Cells\n", "\n", "Cells, can be markdown (text), like this one." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ "A brief note about Markdown. It's a way to specify all formatting within the text itself. \n", "\n", "For example, italicized text can be specified with an _underscore_ or *single asterisks*.\n", "\n", "Bold text requires __two underccores__ or **two asterisks**." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "#### Question #2\n", "\n", "**What does three underscores around text accomplish?**\n", "\n", "- A) bold\n", "- B) italicize\n", "- C) bold + italicize\n", "- D) normal text\n", "- E) I'm lost" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "-" } }, "source": [ "you can write/edit your markdown text here to determine the answer to the question" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "### Markdown Headers\n", "\n", "## Headers are specified with a pound sign\n", "\n", "### The more pound signs, the smaller the header\n", "\n", "#### But it's still larger\n", "\n", "than just plain text.\n" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "Lists are also possible:\n", " \n", "- item 1\n", "- item 2\n", "- item 3\n", "\n", "\n", "1. numbered item\n", "2. item 2\n", "3. item 3" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "#### Question #3\n", "\n", "**What would happen if I specified a numbered list but put the same number before each list item?**\n", "\n", "- A) the list would have the same number before each item\n", "- B) markdown would still format it with sequential numbers\n", "- C) markdown wouldn't know it was a list\n", "- D) normal text with everything on a single line\n", "- E) I'm lost" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "-" } }, "source": [ "test it out down here to see...\n", "\n", "list item\n", "list item \n", "list item" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "#### Code Cells\n", "\n", "Whenever you're writing code, you'll want to be sure the cell is set to be a code cell" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "# Cell can also be code.\n", "a = 1\n", "b = 2" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "# Cells can also have output, that gets printed out below the cell.\n", "c = a - b\n", "print(c)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "# If you execute a cell with just a variable name in it, it will also get printed\n", "c" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "#### Running Cells\n", "\n", "- The numbers in the square brackets to the left of a cell show which cells have been run, and in what order.\n", " - An asterisk (*) means that the cell is currently running\n", " - You do not need to run cells in order! This is useful for flexibly testing and developing code. " ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "### Coding time\n", "\n", "\n", "Write code that outputs the value '6'" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "## YOUR CODE HERE" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "#### Question #4\n", "\n", "**Which of the following best describes you?**\n", "\n", "- A) I completed the task.\n", "- B) I tried but wasn't able to complete the task.\n", "- C) I am not sure where to start." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "### Accessing Documentation" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ "<div class=\"alert alert-success\">\n", "Jupyter has useful shortcuts. Add a single <code>?</code> after a function or class get a window with the documentation, or a double <code>??</code> to pull up the source code. \n", "</div>" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "# For example, execute this cell to see the documentation for the 'abs'\n", "abs?" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "### Autocomplete" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ "<div class=\"alert alert-success\">\n", "Jupyter also has \n", "<a href=\"https://en.wikipedia.org/wiki/Command-line_completion\" class=\"alert-link\">tab complete</a>\n", "capacities, which can autocomplete what you are typing, and/or be used to explore what code is available. (<i>Note</i>: Some of this functionality is limited on datahub.)\n", "</div>" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "# Move your cursor to the end of the line, press tab, and a drop menu will appear showing all possible completions\n", "ra" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "# If there is only one option, tab-complete will auto-complete what you are typing\n", "ran" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "### Installation\n", "\n", "You only need access to datahub for this course, but for working on your projects and for downloading and opening the notebooks used in class, you may want to download anaconda onto your computer, which comes complete with conda, and Jupyter notebooks." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "<center><img src=\"img/anaconda.png\" width=\"450px\"></center>" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ "<div class=\"alert alert-success\">\n", "Anaconda is an open-source distribution of Python, focused on scientific computing in Python. \n", "</div>\n", "\n", "<div class=\"alert alert-info\">\n", "The anaconda website is \n", "<a href=\"https://www.anaconda.com\" class=\"alert-link\">here</a>. \n", "</div>" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## The Anaconda Ecosystem\n", "\n", "- Anaconda itself is a distribution - that is, a copy of the Python standard library, included a curated collection of external packages.\n", "- Conda is a package manager, allowing you to download, install, and manage other packages. " ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ "<div class=\"alert alert-info\">\n", "Download anaconda from\n", "<a href=\"https://www.anaconda.com/download/\" class=\"alert-link\">here</a>.\n", "</div>" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "skip" } }, "source": [ "### Notes\n", "\n", "- If you are on Mac, you have a native installation of Python. This native installation of Python may be older, will not include the extra packages that you will need for this class, and is best left untouched. \n", " - Downloading anaconda will install a separate, independent install of Python, leaving your native install untouched. \n", "- Windows does not require Python natively and so it is not typically pre-installed. " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "slideshow": { "slide_type": "skip" } }, "outputs": [], "source": [ "# You can check which python you are using, and what version it is.\n", "# Once you have installed anaconda, you should see you are using Python in your anaconda folder\n", "# Make sure that the version you have is 3.6 (or at least 3.X)\n", "# Note: these are command-line functions that may not work on windows\n", "!which python\n", "!python --version" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "skip" } }, "source": [ "### Web Browser" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "skip" } }, "source": [ "<div class=\"alert alert-success\">\n", "Jupyter notebooks display in a web browser. They are not hosted on the web, everything is happening locally. \n", "</div>" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "skip" } }, "source": [ "If you click on the url in the browser, you will notice it says 'localhost'. This means it is connected to something locally, on your computer. \n", "\n", "That local connection is to the 'kernel'. " ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## Academic Integrity\n", "\n", "We've had some issues in the past, so we're trying to be incredibly explicit this quarter so that we're all on the same page. (And, because this differs from some other courses.)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ "<center><img src=\"img/academic_integrity.png\" width=\"900px\"></center>\n", "\n", "Correction: It was for one exam; it was not constant. And it was 6/100 (which is 6% of the class!)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ "*I came into this class knowing absolutely nothing about coding. Being in this position, I have made it my goal to go above and beyond in learning about programming languages that I am unfamiliar with because I personally like a challenge and I love learning new things.*\n", "\n", "*Because coding does not come naturally to me, I plan WAY ahead of time as to when I need to sit down, uninterrupted, to really learn, make mistakes, and test out the code I write in assignments. For example, I plan DAYS ahead of time as to when I need to sit down and complete assignments. Again, because coding does not come naturally to me, I spend on average 2 hours more than the median hours/time spent listed. Not only do I spend hours completing assignments to the best of my ability, but I make sure to test out EACH AND EVERY PIECE of code I wrote in these assignments to make sure my code is “spitting out” what I am expecting, and to show you and the TAs what I was trying to do just in case I get something wrong (because showing work for some points is better than showing no work for 0 points, you know?)* \n", "\n", "*Each student has their method, and planning out WHEN to work and HOW LONG to work on assignments is my method; I just think it is a shame that students resort to cheating when things get tough or they are too lazy to actually learn, because again, that is unfair to me as a student who dedicates time and energy to every assignment in this class.* \n", "\n", "\\- Former COGS 18 Student" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ "The most important reminder: **you must have written, understand, and be able to explain any code you turn in as your own.**" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ "When *can* you work with others in COGS 18?\n", "- Coding Labs\n", "- Assignments" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ "Working with others is *different* than copying from others. It is *never* acceptable to just ask someone for their answers or their code. \n", "\n", "On Coding Labs & Assignments, it *is* OK to ask one another questions *about* what you're working on. It is OK to share screens and talk through your answers.\n", "\n", "If you find yourself copying + pasting someone else's code (from a friend or from the Internet)...you're probably making a mistake." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ "When can you NOT work with others?\n", "- Exams\n", "\n", "Exams are the only time in this course we ask you to work on material completely on your own. " ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ "Exams assess *your* understanding after you've had plenty of practice (in lecture, on coding labs, and on assignments).\n", "\n", "It's your time to show off what you know." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ "Exams are open notes and open Google. \n", "\n", "You *can* search the Internet for help on concepts.\n", "\n", "You are not allowed to ask anyone specific questions from the Exam or post the questions anywhere." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ "Part of your first Coding Lab will help to make this all as clear as possible!" ] } ], "metadata": { "celltoolbar": "Slideshow", "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.11.8" }, "rise": { "scroll": true } }, "nbformat": 4, "nbformat_minor": 4 }