diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..e7554af --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,52 @@ +name: deploy-book + +# Only run this when the master branch changes +on: + workflow_dispatch: + push: + branches: + - main + +# This job installs dependencies, build the book, and pushes it to `gh-pages` +jobs: + deploy-book: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + # Install dependencies + - name: Set up Python 3.10 + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: cache installation + uses: actions/cache@v3 + with: + path: ${{ env.pythonLocation }} + key: ${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements.txt') }} + + - name: Install dependencies + run: | + pip install -r requirements.txt + # Build the book + - name: Build the book + run: | + jupyter-book build . + + # Push to server + - name: rsync and ssh + env: + REMOTE_HOST: ${{ secrets.FIRAS_REMOTE_HOST }} + REMOTE_USER: ${{ secrets.FIRAS_REMOTE_USER }} + REMOTE_KEY: ${{ secrets.FIRAS_SERVER_SSH_KEY }} + REMOTE_DIR: ${{ secrets.FIRAS_REMOTE_TARGET }} + LOCAL_DIR: "_build/html/" + COURSE_NAME: "cpsc455" + TERM: "2024_S" + run: | + mkdir ~/.ssh + echo "$REMOTE_KEY" > ~/.ssh/id_rsa + ssh-keyscan -H $REMOTE_HOST >> ~/.ssh/known_hosts + chmod 600 ~/.ssh/id_rsa + rsync -avzr --delete $LOCAL_DIR $REMOTE_USER@$REMOTE_HOST:$REMOTE_DIR/$COURSE_NAME/$TERM diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..08d37a4 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Firas Moosvi + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index ded5396..8473299 100644 --- a/README.md +++ b/README.md @@ -1 +1,46 @@ -# cpsc455 \ No newline at end of file +# CPSC 455 + +## Features + +1. Support for executing code in a browser using [thebe](https://thebe.readthedocs.io/en/latest/) and [mybinderorg](https://mybinder.org)! + +1. Structured book with markdown file stubs aligning with a course structure for a 13 week course. Fully versioned using GitHub, automatically deployed using GH Actions to either GH or your own server. Can also be extended with a testing framework for extra peace of mind. + +1. [Examples of how to use IFrames](https://firasm.github.io/jupyterbook_course_template/notes/topic1.html#) to embed web content, @phet_sims, @sli.do polls, videos, and other content. + +1. Powerful built-in annotation and commenting features with [hypothes.is](http://hypothes.is) and [utteranc.es](http://utteranc.es). Annotate your syllabus, course readings, and any other content. + +1. Add persistent checkboxes so students can track their progress through notebooks, exercises and readings. + +1. Allow students to download pages of the site in PDF, link to the source code on your repo, or open in a mybinder notebook. + +1. The JupyterBook can be embedded into Canvas using the Redirect tool so students never have to leave their LMS. + +1. (NEW!) Use of the new `substitution` feature of [myst-parser](https://myst-parser.readthedocs.io/en/latest/develop/_changelog.html#id1) to configure the course algorithmically from the `_config.yml` file! + +## Edit the template for your course + +There are a few things you need to do to adapt this template for your course. +I might miss a few things, so this list is a work in progress: + +1. In the `_config.yml` file: + + - [ ] Set title of the book (Physics 111) + - [ ] Update author (Firas Moosvi) + - [ ] Update logo image (images/logo.png) + - [ ] Add Google Analytics ID (Optional) + - [ ] Enable/Disable Hypothes.is (remove the line to remove the hypothes.is integration) + - [ ] Configure Utteranc.es repository (Choose one of Hypothesis or Utteranc.es) + - [ ] Adjust `extra_footer` to control License of course materials + - [ ] Set the substitution parameters under the `myst_substitutions` + +1. In the `_toc.yml` file: + - [ ] Arrange the table of contents to add/remove files + +1. In the `about` and `class` folders: + - [ ] Edit the .md and .ipynb files with your course content + +## Attribution + +- Thanks the entire [Jupyter Project](https://jupyter.org/about) +- Finally, a big thanks to the [JupyterBook community](https://github.com/executablebooks/jupyter-book/graphs/contributors) for my incessant issues, questions, and PR requests on documentation changes. diff --git a/_config.yml b/_config.yml new file mode 100755 index 0000000..4e48256 --- /dev/null +++ b/_config.yml @@ -0,0 +1,108 @@ +# Book settings +title: CPSC 455 +author: Firas Moosvi and Ian McLean +logo: images/logo.jpg +copyright: "" +exclude_patterns: ["LICENSE.md", "README.md"] +only_build_toc_files: true + +bibtex_bibfiles: + - about/citations.bib + +latex: + latex_documents: + targetname: book.tex +html: + home_page_in_navbar : true + use_repository_button: true + use_issues_button: true + use_edit_page_button: true + navbar_number_sections : false + # announcement: "Use this JupyterBook as a template by clicking here!" # The base URL where your book will be hosted. Used for creating image previews and social links. e.g.: https://mypage.com/mybook/ + # google_analytics_id: UA-11111111 # add your Google Analytics Tracking Code + comments: + hypothesis: false + utterances: + repo: "UBC-CS/cpsc455" + dokieli: false + extra_footer : | +
+ + All content on this site (unless otherwise specified) is licensed under the CC BY-NC-SA 4.0 license +
+ +# launch_buttons: +# notebook_interface : "jupyterlab" +# binderhub_url : "https://mybinder.org" +# thebe : true + +repository: + url : https://github.com/UBC-CS/cpsc455 + path_to_book : "" + branch : main + +sphinx: + config: + html_show_copyright: false + html_extra_path: ['files'] + bibtex_reference_style: author_year + myst_heading_anchors: true + myst_heading_anchors: 3 + myst_enable_extensions: + - amsmath + - colon_fence + - deflist + - dollarmath + - html_image + - linkify + - replacements + - substitution + + myst_substitutions: + # Instructor information + INSTRUCTOR: "Dr. Firas Moosvi (he/his/him) and Ian" + PRONOUNCE: "Fur-az Moose-vee" + OFFICE: "ICCS 253" + PHONE: "N/A" + + # Course Information + COURSE_CODE: "CPSC 455" + SECTION: "901" + CREDITS: "3" + TITLE: "Applied Industry Practices" + PREREQS: "Pre-reqs: One of CPSC 310, CPEN 321." + COREQS: "N/A" + TERM: "2024 Summer Term" + ROOM: "Online" + MEETING_TIMES: "Every other Saturday starting May 11th" + # FORMAT: "Lectures, Labs, Tutorials will all be running in-person." + + # Important Links + CANVAS_ID: "142514" + CANVAS_LINK: "https://canvas.ubc.ca/courses/CANVAS_ID" + ZOOM_LINK: "[Zoom](https://canvas.ubc.ca/courses/CANVAS_ID/external_tools/15408)" + ANNOUNCEMENTS_LINK: "[Canvas Announcements](https://canvas.ubc.ca/courses/CANVAS_ID/announcements)" + COURSE_LINK: "https://firas.moosvi.com/courses/cpsc455/2024S/" + FORUM_LINK: "[Ed Discussion](https://edstem.org/us/join/xyhhmY)" + TEXTBOOK: "We will not be needing a textbook for this course as you will be provided all the notes you need via the course website and linked materials." + ANON_FEEDBACK: "[feedback form](https://ubc.ca1.qualtrics.com/?course=cpsc455&term=2024_S)" + ASSOCIATE_HEAD: "Associate Head [associate.head@fakeemail.ca](mailto:associate.head@fakeemail.ca)" + ANALYTICS_OPTOUT: "[complete this form](https://ubc.ca1.qualtrics.com/jfe/form/SV_0p6lP4TtNpJn410/?course=cpsc455&term=2024_S)" + + # Withdrawal Dates and Exam Period + # https://vancouver.calendar.ubc.ca/dates-and-deadlines + W_DATE_1: "11:59 PDT on January 19, 2024" + W_DATE_2: "11:59 PDT on March 1, 2024" + W_DATE_3: "11:59 PDT on March 1, 2024" + EXAM_PERIOD: "Tuesday April 16th - Saturday, April 27" + + # Course Policies + GRACE_PERIOD: "48 hour" + + # TA Names + TA1: "Braeden Fong" + TA1pronounce: "BRAY-DIN" + TA2: "Manushree Singhania" + TA2pronounce: "MA-NU-SHREE" + TA3: "Minh Anh Nguyen" + TA3pronounce: "Ming Ang" \ No newline at end of file diff --git a/_static/custom_layouts.css b/_static/custom_layouts.css new file mode 100644 index 0000000..7cc5d4e --- /dev/null +++ b/_static/custom_layouts.css @@ -0,0 +1,11 @@ +/********************************************* +* Print-specific CSS * +*********************************************/ + +.table td, .table th{ + padding: 0.2rem +} + +.row-odd p, .row-even p{ + margin-bottom: 0 +} \ No newline at end of file diff --git a/_static/extra.css b/_static/extra.css new file mode 100644 index 0000000..55ddac5 --- /dev/null +++ b/_static/extra.css @@ -0,0 +1,36 @@ +/* Responsive IFrames +Source: https: //www.w3schools.com/howto/howto_css_responsive_iframes.asp +*/ + +.youtube { + position: relative; + overflow: hidden; + width: 100%; + padding-top: 56.25%; + /* 16:9 Aspect Ratio (divide 9 by 16 = 0.5625) */ +} + +/* Then style the iframe to fit in the container div with full height and width */ +.responsive-iframe { + position: absolute; + top: 0; + left: 0; + bottom: 0; + right: 0; + width: 100%; + height: 100%; +} + +/* remove space above dropdowns */ + +.dropdown-margin{ + margin: 0; + position: relative; +} + +.sticky { + position: -webkit-sticky; + /* Safari */ + position: sticky; + top: 0; +} \ No newline at end of file diff --git a/_static/pdf_print.css b/_static/pdf_print.css new file mode 100644 index 0000000..0f766b7 --- /dev/null +++ b/_static/pdf_print.css @@ -0,0 +1,30 @@ +/********************************************* +* Print-specific CSS * +*********************************************/ + +@media print { + + div.topbar { + display: none; + } + + .pr-md-0 { + flex: 0 0 100% !important; + max-width: 100% !important; + } + + .page_break { + /* + Control where and how page-breaks happen in pdf prints + This page has a nice guide: https://tympanus.net/codrops/css_reference/break-before/ + This SO link describes how to use it: https://stackoverflow.com/a/1664058 + + Simply add an empty div with this class where you want a page break + like so:
; + */ + clear: both; + page-break-after: always !important; + break-after: always !important; + } + +} \ No newline at end of file diff --git a/_static/plausible_cpsc455.js b/_static/plausible_cpsc455.js new file mode 100644 index 0000000..6276d46 --- /dev/null +++ b/_static/plausible_cpsc455.js @@ -0,0 +1,13 @@ +// NOTE: This file allows my privacy-focused analytics provider (Plausible) to +// collect data on various aspects of usage. +// Those that are using this repo as a template should REMOVE this file from their repo + +var script = document.createElement("script"); +script.defer = true; +script.src = "https://plausible.io/js/script.js"; +script.dataset.domain = "cpsc455"; + +// optional if using proxy +// script.dataset.api = 'https://yourproxy.com/api/event'; + +document.getElementsByTagName("head")[0].appendChild(script); diff --git a/_static/save_state.js b/_static/save_state.js new file mode 100644 index 0000000..e366ca3 --- /dev/null +++ b/_static/save_state.js @@ -0,0 +1,32 @@ + +/* This code is copied verbatim from this SO post by Rory McCrossan: https://stackoverflow.com/a/51543474/2217577. + +The code was shared under the CC BY-SA 4.0 license: https://creativecommons.org/licenses/by-sa/4.0/ + +It's purpose is to simply store the state of checked boxes locally as a localStorage object. + +To use it, simply add checkboxes as normal within your md files: + + Item 1 + Item 2 + Item 3 + +*/ + +function onClickBox() { + var arr = $('.box').map(function() { + return this.checked; + }).get(); + localStorage.setItem("checked", JSON.stringify(arr)); +} + +$(document).ready(function() { + var arr = JSON.parse(localStorage.getItem('checked')) || []; + arr.forEach(function(checked, i) { + $('.box').eq(i).prop('checked', checked); + }); + + $(".box").click(onClickBox); +}); + + diff --git a/_toc.yml b/_toc.yml new file mode 100755 index 0000000..33e3be9 --- /dev/null +++ b/_toc.yml @@ -0,0 +1,183 @@ +format: jb-book +root: about/unsyllabus +parts: +- caption: About this course + chapters: + # - file: about/syllabus + - file: about/course_schedule + # - file: about/accommodations + # - file: about/doing_well + # - file: about/faq + +# - caption: Getting Started +# chapters: +# - file: getting-started/pre_term +# - file: getting-started/tasks1 +# - file: getting-started/tasks2 +# - file: getting-started/tasks3 +# - file: notes/setup/stack +# title: Setup Your Machine +# sections: +# - file: notes/setup/install_macOS +# - file: notes/setup/install_windows + # - file: notes/setup/install_ubuntu + +# - caption: Demo section +# chapters: +# - file: notes/demo01/demo01_summary +# title: Demo 1 - Data Science +# sections: +# - file: notes/demo01/lecture1 +# - file: notes/demo01/lecture2 +# - file: notes/demo01/lecture3 +# - file: notes/demo02/demo02_summary +# title: Demo 2 - Introductory Physics +# sections: +# - file: notes/demo02/videos +# - file: notes/demo02/homework +# - file: notes/demo02/readings +# - file: notes/demo02/lab +# - file: notes/demo02/learninglogs +# - file: notes/demo02/test +# - file: notes/demo03/demo03_summary +# title: Demo 3 - Shakespeare +# - file: notes/demo04/demo04_summary +# title: Demo 4 - Chemistry +# - url: https://firas.moosvi.com/books/active-learning-technologies/jupyterdays/capacitor_talk/Capacitor.html +# title: Capacitor Lecture + +# - caption: Part 1 - Introductions +# maxdepth: 1 +# chapters: +# - file: notes/week01/week01_summary +# title: Week 1 - Introductions! +# sections: +# - file: notes/week01/class1A +# - file: notes/week01/class1B +# - file: notes/week02/week02_summary +# title: Week 2 - Python Review +# sections: +# - file: notes/week02/videos +# - file: notes/week02/class2A +# - file: notes/week02/class2B +# - file: notes/week02/homework +# - file: notes/week02/lecture +# - file: notes/week02/test +# - file: notes/week02/lab +# - file: notes/week02/learninglogs +# - caption: Part 2 - Dataclass in Python +# chapters: +# - file: notes/week03/week03_summary +# title: Week 3 - Efficiency and Dataclass +# sections: +# # - file: notes/week03/readings +# - file: notes/week03/videos +# - file: notes/week03/class3A +# - file: notes/week03/class3B +# - file: notes/week03/homework +# - file: notes/week03/lecture +# - file: notes/week03/test +# - file: notes/week03/lab +# - file: notes/week03/learninglogs + # - file: notes/week04/week04_summary + # title: Week 4 - Dataclass cont'd + # sections: + # - file: notes/week04/readings + # - file: notes/week04/videos + # - file: notes/week04/class4A + # - file: notes/week04/class4B +# - file: notes/week04/homework +# - file: notes/week04/lecture +# - file: notes/week04/test +# - file: notes/week04/lab +# - file: notes/week04/learninglogs +# - caption: Part 3 - Working with Data +# chapters: +# - file: notes/week05/week05_summary +# title: Week 5 - Web Scraping +# sections: +# - file: notes/week05/videos +# - file: notes/week05/class5A +# - file: notes/week05/class5B +# - file: notes/week05/readings + +# - file: notes/week05/homework +# - file: notes/week05/lecture +# - file: notes/week05/test +# - file: notes/week05/lab +# - file: notes/week05/learninglogs +# - file: notes/week06/week06_summary +# title: Week 6 - Git and Version Control +# sections: +# - file: notes/week06/videos +# - file: notes/week06/class6A +# - file: notes/week06/class6B +# - file: notes/week07/week07_summary +# title: Week 7 - Reading week! + +# - caption: Part 4 - Algorithms and Data Structures +# chapters: +# - file: notes/week08/week08_summary +# title: Week 8 - Data Structures +# sections: +# - file: notes/week08/videos +# - file: notes/week08/class8A +# - file: notes/week08/class8B +# - file: notes/week09/week09_summary +# title: Week 9 - Graphs +# sections: +# - file: notes/week09/videos +# - file: notes/week09/class9A +# - file: notes/week09/class9B +# - file: notes/week11/week11_summary +# title: Week 11 - MHall +# sections: +# - file: notes/week11/videos +# - file: notes/week11/class11A +# - file: notes/week11/class11B +# - file: notes/week12/week12_summary +# title: Week 12 - State Spaces +# sections: +# - file: notes/week12/videos +# - file: notes/week12/class12A +# - file: notes/week12/class12B +# - file: notes/week13/week13_summary +# title: Week 13 - Maps +# sections: +# - file: notes/week13/videos +# - file: notes/week13/class13A +# - file: notes/week13/class13B +# - file: notes/week14/week14_summary +# title: Week 14 - Natural Language Processing (Optional) +# sections: +# - file: notes/week14/class14A + # - file: notes/week14/class14B + # - file: notes/week14/videos +# - caption: Week 13 - Exam Review +# chapters: +# - file: notes/week13/week13_summary +# title: Week 13 - Review +# sections: +# - file: notes/week13/readings +# - file: notes/week13/videos +# - file: notes/week13/homework +# - file: notes/week13/lecture +# - file: notes/week13/test +# - file: notes/week13/lab +# - file: notes/week13/learninglogs +# - caption: Final Exam +# chapters: +# - file: notes/final +# - caption: Lab Materials +# chapters: +# - file: notes/labs +# title: Lab Stuff +- caption: Course Feedback + chapters: + - file: about/feedback + title: Anonymous Feedback Form + +# - caption: Tools +# chapters: +# - file: tools/ed_discussion/ed_discussion +# - file: tools/github/github \ No newline at end of file diff --git a/about/accommodations.md b/about/accommodations.md new file mode 100755 index 0000000..b96b2cf --- /dev/null +++ b/about/accommodations.md @@ -0,0 +1,6 @@ +(page_Accommodations)= +Accommodations +======================= + +The Centre for Accessibility ensures educational equity for students with disabilities, injuries or illness. +If you are disabled, have an injury or illness and require academic accommodations to meet the course objectives, [visit the CFA website](https://students.ubc.ca/about-student-services/centre-for-accessibility) for more information or contact the CFA at: [info.accessibility@ubc.ca](mailto:info.accessibility@ubc.ca). \ No newline at end of file diff --git a/about/citations.bib b/about/citations.bib new file mode 100644 index 0000000..0ec44c5 --- /dev/null +++ b/about/citations.bib @@ -0,0 +1,25 @@ +@article{Rumore2016, +author = {Rumore, Martha M}, +title = {{The Course Syllabus: Legal Contract or Operator’s Manual?}}, +issn = {0002-9459}, +doi = {10.5688/ajpe8010177}, +pmid = {28179726}, +abstract = {{A course syllabus provides a roadmap for pharmacy students to achieve course learning objectives and develop lifelong learning skills. For several decades the literature has referred to syllabi as legal documents and/or contracts between students and professors. A review of the legal precedents reveals that syllabi are not considered contracts because the courts refuse thus far to recognize educational malpractice or breach of contract as a cause of action. Syllabi do, however, represent a triggering agent for instructional dissent and grade appeals, may be binding in student appeal proceedings, and are used in judicial hearings. Pharmacy faculty members should review their syllabi and follow process improvement strategies to construct legally sound syllabi that can both enhance learning and minimize risks of student grievances and appeals.}}, +pages = {177}, +number = {10}, +volume = {80}, +journal = {American Journal of Pharmaceutical Education}, +local-url = {file://localhost/Users/firasm/Documents/Papers%20Library/Rumore-The%20Course%20Syllabus-%20Legal%20Contract%20or%20Operator’s%20Manual--2016-American%20Journal%20of%20Pharmaceutical%20Education.pdf}, +year = {2016} +} +@book{Ambrose2010, +author = {Ambrose, Susan A. and Bridges, Michael W. and DiPietro, Michele and Lovett, Marsha C. and Norman, Marie K.}, +title = {{How Learning Works: 7 Research-Based Principles for Smart Teaching}}, +isbn = {978-0-470-48410-4}, +year = {2010}, +shorttitle = {How Learning Works}, +publisher = {Jossey-Bass}, +address = {San Francisco, CA}, +language = {English}, +local-url = {file://localhost/Users/firasm/Documents/Papers%20Library/How-Learning-Works.pdf} +} \ No newline at end of file diff --git a/about/course_schedule.md b/about/course_schedule.md new file mode 100755 index 0000000..0779095 --- /dev/null +++ b/about/course_schedule.md @@ -0,0 +1,6 @@ +(page_Course_Schedule)= +Course Schedule +======================= + +```{include} syllabus_bits/schedule.md +``` \ No newline at end of file diff --git a/about/doing_well.md b/about/doing_well.md new file mode 100644 index 0000000..9bfca87 --- /dev/null +++ b/about/doing_well.md @@ -0,0 +1,93 @@ +(page_doing_well)= +How to do well in this course +======================= + +```{note} +Credit for the original version of this document goes to [Dr. Simon Bates](https://sites.google.com/site/simonpbates/home?authuser=0) from Physics 117 at UBC-Vancouver. + +The material below has been used and adapted with his permission. +``` + +## Introduction + +Your success in this course depends to a large extent how you approach it, and how you engage with the activities, the materials and each other. +Here, we give you some ideas and advice on how to do well in the course that you might find useful as you embark on the course. +But before that, here are some key ideas about learning that we have used in designing this course activities and assessments: + +### Learning is a contact sport. + +It’s not like watching a good movie, where you can just let it wash over you. +You have to engage to really learn; you have to struggle to learn. +It’s hard, it sometimes won’t make sense and it takes time and persistence. +You might have found learning (and passing exams) pretty easy to this point; university might well be very different. + +### Memorizing is not learning. + +We won't emphasize memorizing in this course. +Every test you do, you can take in your own notes (we call these ‘open note’ tests). +So more important than remembering every single equation we will use, is knowing when to use which ones, how to use them to solve problems and evaluating if what you’ve calculated makes sense. + +### Understanding is learning and understanding should be your goal. + +Can you explain an idea or a concept from this course to someone else in a way that they will understand it? +And some time after you studied it? This is the acid test for learning and it is one reason why we place such a lot of value on interaction and communication with your peers in this course. + +### We’ll do lots of tests. + +Why? Because research shows testing improves learning. +It might seem counterintuitive, but by taking a test, what we recall becomes more recallable in the future. +In a sense, you are practicing what you are going to need to do for the final, and more importantly for longer term retention of the skills you will learn in this class. + +## Ingredients for your success + +Even with all these key ideas about learning, the most important ingredients need to come from you. +Here are some of the things we think you need to think about at the start of the course: + +### Plan + +Spend some time thinking about how you are going to plan your work on this course. +It requires you to schedule 2-3 hours per week of self-study and outside-class time for pre-reading and practice. +Just turning up to lecture and tutorials will not be enough. +Lectures will not present material; they will reinforce and consolidate your understanding of it. +If you have never taken a course like this, you might consider thinking a bit more about how to best prepare for the classes. + +### Prepare + +Read the material for this weeks pre-reading carefully ahead of the classes that follow. +Don’t skim it, don’t hunt for answers to the quiz; make notes and engage in discussions with your classmates on Piazza (or Discord) for things you don’t understand. +You need some basic familiarity or fluency with the content before we can make the most of the precious class time we have together. + +### Engage + +Engage with us, with your peers and yourself. +Be an active learner; participate in face-to-face classes and online – discuss with peers, and ask questions. +Most of all, ask yourself ‘does this make sense?’ If it doesn’t, do something about it! + +### Practice + +The way we assess most of this course will be on your ability to solve problems; numerical and conceptual ones. +So, solve problems as practice: lots of problems. +If the problems we set you are too easy, make up problems. +Practice not just solving but how to get started on problems. + Work with a problem solving strategy so you don’t have to say 'I don’t know where to start' + +### Collaborate + +Your peers are a fantastic resource for your understanding. +Don’t get isolated; form a study group, use Piazza and/or Discord , go to the Drop-in sessions. +Try not to fall behind (it’s hard to catch up if you do) but do talk to us if you really are struggling. + +### Be careful not to be complacent + +Don’t be fooled by the familiarity of some of this material! +You may have seen most of it before. +This may lead you to expect that you have little new to learn here. +We found that students come with huge misconceptions about seemingly familiar ideas. +You need to be prepared to let go of them if you are to really master these foundations of the subject and this course. + +### Math + +Ah yes, finally, **math**. +You need a relevant math co-requisite for this course. +We will assume that you are comfortable with the following (and can do them quickly and easily): scientific notation, unit conversions, order of magnitude estimates, significant figures, trig, algebra, sketching and interpreting graphs, basic differentiation (and a touch of integration too). +Early in the course, you will get a chance to diagnose any gaps in your own math knowledge. \ No newline at end of file diff --git a/about/faq.md b/about/faq.md new file mode 100755 index 0000000..81effc6 --- /dev/null +++ b/about/faq.md @@ -0,0 +1,13 @@ +Frequently Asked Questions +======================= + +```{dropdown} What should I do if I'm joining the course late? + :class-container: sd-shadow-lg + :color: primary + :name: joining-late + :open: + +Since I generally teach large classes, this happens quite often! No worries, we'll get you all caught up. I've recorded a quick video showing you how to get oriented with one of my courses. You can [watch the video here](https://vimeo.com/firasmoosvi/joining-late) or watch the embedded version below: + +
+``` \ No newline at end of file diff --git a/about/feedback.md b/about/feedback.md new file mode 100644 index 0000000..0b3456b --- /dev/null +++ b/about/feedback.md @@ -0,0 +1,8 @@ +(page_feedback)= +# {{ COURSE_CODE }} Anonymous Feedback Form + +Please let me know if you have any comments, thoughts, questions, and feedback about the course or me as an instructor. This form is completely anonymous and no identifiable information will be collected or stored. I hope you will consider this a safe space to provide genuine feedback to your instructor (Firas Moosvi). + +Note that despite the fact that this form is anonymous and I will never find out who you are, I urge you to still be respectful, courteous, and professional. Don't forget, I am human too! + + \ No newline at end of file diff --git a/about/syllabus.md b/about/syllabus.md new file mode 100644 index 0000000..428798e --- /dev/null +++ b/about/syllabus.md @@ -0,0 +1,88 @@ +![](../images/header.jpg) + +![](../images/UBC_CS.png) + +# Course Syllabus (Official) + +Below is the official UBC-mandated Course Syllabus for {{ COURSE_CODE }}. +Elements of this document are **fixed** and unchanging. +Additional details about the course are available on the {{ '[course website]({link})'.format(link=CANVAS_LINK.replace('CANVAS_ID',CANVAS_ID))}}. + +## Land Acknowledgement + +```{include} syllabus_bits/land_acknowledgement.md +``` + +## Course Information + +```{include} unsyllabus_bits/important_details.md +``` + +For information on how to contact your course instructor, including office hours, see the {{ '[course website]({link})'.format(link=COURSE_LINK)}}. + +## Calendar Description + +```{include} syllabus_bits/calendar_entry.md +``` + +## Other Instructional Staff + +For information on this, see the {{ '[course website]({link})'.format(link=COURSE_LINK)}}. + +## Learning Outcomes + +The Learning Outcomes for this course are: + +```{include} syllabus_bits/course_LOs.md +``` + +More details about the course can be found on the {{ '[course website]({link})'.format(link=CANVAS_LINK.replace('CANVAS_ID',CANVAS_ID))}}. + +## Schedule of Topics + +The tentative course schedule, subject to change, can be found on the {{ '[course website]({link})'.format(link=CANVAS_LINK.replace('CANVAS_ID',CANVAS_ID))}}. + +```{include} syllabus_bits/schedule.md +``` + +## Course Structure + +For information on this, see the {{ '[course website]({link})'.format(link=COURSE_LINK)}}. + +## Learning Activities + +For information on this, see the {{ '[course website]({link})'.format(link=COURSE_LINK)}}. + +## Learning Materials + +There is no requirement to purchase textbooks or any other materials for this course. +Resources and materials for this course can be found on the {{ '[course website]({link})'.format(link=CANVAS_LINK.replace('CANVAS_ID',CANVAS_ID))}}. + +## Assessments of Learning + +```{include} syllabus_bits/grading_practices_simple.md +``` + +## Passing Criteria + +```{include} syllabus_bits/passing_requirement.md +``` + +## Late Policy and Missed Assignments and Exams + +Due dates in this course have a generous no-penalty {{ GRACE_PERIOD }} grace period so late submissions are not generally accepted. +Missed Tests and Exams will be given a score of 0 unless prior arrangements are made with the course instructor. +To contact the instructor for this course, use {{ FORUM_LINK }}. +Details on due dates and other course policies can be found on the {{ '[course website]({link})'.format(link=CANVAS_LINK.replace('CANVAS_ID',CANVAS_ID))}}. + +## Learning Analytics + +```{include} syllabus_bits/learning_analytics.md +``` + +## Learning Resources + +For information on this, see the {{ '[course website]({link})'.format(link=COURSE_LINK)}}. + +```{include} syllabus_bits/policies.md +``` \ No newline at end of file diff --git a/about/syllabus_bits/calendar_entry.md b/about/syllabus_bits/calendar_entry.md new file mode 100644 index 0000000..a12d687 --- /dev/null +++ b/about/syllabus_bits/calendar_entry.md @@ -0,0 +1,15 @@ +**{{ COURSE_CODE }} ({{ CREDITS }}) {{ TITLE }}** + +The [UBC calendar description](https://vancouver.calendar.ubc.ca/course-descriptions/subject/phys) of this course is: + +> Introduction to mechanics primarily for students majoring in the physical sciences (e.g. physics, chemistry, mathematics, computer science, geology, physical geography) or engineering. +> Particle kinematics and dynamics, work and energy, momentum, gravitation, rigid body motion, fluid statics and dynamics with applications to the physical sciences. +> Credit will be granted for only one of PHYS 111 and PHYS 112. Students with Physics 12 may apply for a tutorial exemption. [3-3-1] +> +> *Prerequisite*: {{ PREREQS }} +> +> *Corequisite*: {{ COREQS }} + +```{warning} +If there is a lab and/or tutorial listed on the SSC for this course, You **must** register for all course elements without conflicts, otherwise the department will remove you from the course! There are usually lab or tutorial exemptions for some students (i.e. those repeating the course) and instructions for that will be in this syllabus. +``` \ No newline at end of file diff --git a/about/syllabus_bits/course_LOs.md b/about/syllabus_bits/course_LOs.md new file mode 100644 index 0000000..5f02009 --- /dev/null +++ b/about/syllabus_bits/course_LOs.md @@ -0,0 +1,7 @@ +The learning intentions for this course are currently under development! + + \ No newline at end of file diff --git a/about/syllabus_bits/course_teaser.md b/about/syllabus_bits/course_teaser.md new file mode 100644 index 0000000..66a3112 --- /dev/null +++ b/about/syllabus_bits/course_teaser.md @@ -0,0 +1,24 @@ +This course will be a LOT of fun, you'll get lots of practice doing a lot of Python, and you'll learn some cool things. + +By the end of the course, you'll (hopefully) feel super comfortable with algorithms and programming. +Strap in, it will be a wild ride!! + + diff --git a/about/syllabus_bits/grading_practices_simple.md b/about/syllabus_bits/grading_practices_simple.md new file mode 100644 index 0000000..54b85ba --- /dev/null +++ b/about/syllabus_bits/grading_practices_simple.md @@ -0,0 +1,14 @@ +| Item | Weight | Frequency | +|----------------------|--------|-------------------| +| Learning Logs | 5% | Weekly | +| Problems of the week | 25% | Weekly | +| Labs | 5% | Weekly | +| Programming Projects | 15% | Three in the term | +| Tests (Examlets) | 30% | \~ Bi-weekly | +| Final Exam | 20% | Exam Period | + +Final grades will be based on the evaluations listed above and the final grade will be assigned according to the standardized grading system outlined in the [UBC Calendar](https://vancouver.calendar.ubc.ca/campus-wide-policies-and-regulations/grading-practices/introduction). + +```{note} +Please refer to [this page](https://students.ubc.ca/enrolment/exams/exam-clashes-hardships-cancellations) for details on exam clashes, hardships, and cancellations. +``` \ No newline at end of file diff --git a/about/syllabus_bits/land_acknowledgement.md b/about/syllabus_bits/land_acknowledgement.md new file mode 100644 index 0000000..dc9f7bc --- /dev/null +++ b/about/syllabus_bits/land_acknowledgement.md @@ -0,0 +1,4 @@ +UBC’s Point Grey Campus is located on the traditional, ancestral, and unceded territory of the xwməθkwəy̓əm (Musqueam) people. +The land it is situated on has always been a place of learning for the Musqueam people, who for millennia have passed on their culture, history, and traditions from one generation to the next on this site. + +Aerial photo of the UBC campus showing the Martha Piper fountain, and mountains in the skyline. \ No newline at end of file diff --git a/about/syllabus_bits/learning_analytics.md b/about/syllabus_bits/learning_analytics.md new file mode 100644 index 0000000..87b68fd --- /dev/null +++ b/about/syllabus_bits/learning_analytics.md @@ -0,0 +1,18 @@ +I am very aware of the surveillance culture that has permeated our society and heralded the [End of Privacy](https://www.youtube.com/watch?v=NesTWiKfpD0) as we know it. +That being said, as an instructor, I care tremendously about your learning and the course-related data that is collected about you is extremely valuable. +Broadly speaking, this relatively new field is called **Learning Analytics**. +[Learning Analytics](https://www.solaresearch.org/about/what-is-learning-analytics/) involves the collection and analysis of data about learners for the [express purpose](https://www.collinsdictionary.com/dictionary/english/the-express-purpose-of) of improving their learning by optimizing teaching and learning practices. + +All of the tools above log data about your activity that can be used to improve the quality of teaching and learning. +In this course, I intend to use this information to: + +- view overall class progress (in aggregate), +- track your personal progress in order to provide you with personalized feedback, +- track participation in discussion forums +- improve the course and your learning, +- explore students actions in the course, +- provide you feedback on your progress. + +Unfortunately, at the moment it is not possible to opt-out of the data collection process, but if you like, you may opt-out of the process where *I use the data to give you personalized feedback*. +To opt-out, please {{ ANALYTICS_OPTOUT }} at any point in the course. +You may opt-out with my full support, I respect your decision and applaud you for your netizenship! \ No newline at end of file diff --git a/about/syllabus_bits/passing_requirement.md b/about/syllabus_bits/passing_requirement.md new file mode 100644 index 0000000..c46d8ce --- /dev/null +++ b/about/syllabus_bits/passing_requirement.md @@ -0,0 +1,6 @@ +- All students must satisfy ALL conditions to pass the course: + 1. Pass the Lab component with a grade of at least 50%, + 1. Pass the Test and Exam components (together) with a grade of at least 50%, + 1. Pass the Final Exam with a grade of at least 40%. + +If students do not satisfy the appropriate requirements, the student will be assigned the **lower** of their earned course grade or, a maximum overall grade of 45 in the course. \ No newline at end of file diff --git a/about/syllabus_bits/policies.md b/about/syllabus_bits/policies.md new file mode 100644 index 0000000..0875a8f --- /dev/null +++ b/about/syllabus_bits/policies.md @@ -0,0 +1,95 @@ +## University Policies + +UBC provides resources to support student learning and to maintain healthy lifestyles but recognizes that sometimes crises arise and so there are additional resources to access including those for survivors of sexual violence. +UBC values respect for the person and ideas of all members of the academic community. +Harassment and discrimination are not tolerated nor is suppression of academic freedom. +UBC provides appropriate accommodation for students with disabilities and for religious observances. +UBC values academic honesty and students are expected to acknowledge the ideas generated by others and to uphold the highest academic standards in all of their actions. + +Details of the policies and how to access support are available on the [UBC Senate website](Details of the policies and how to access support are available on the UBC Senate website.). + +## Final Examinations + +The examination period for {{ TERM }} is {{ EXAM_PERIOD }}. +Except in the case of examination clashes and hardships (three or more formal examinations scheduled within a 24-hour period) or unforeseen events, students will be permitted to apply for out-of-time final examinations only if they are representing the University, the province, or the country in a competition or performance; serving in the Canadian military; observing a religious rite; working to support themselves or their family; or caring for a family member. +Unforeseen events include (but may not be limited to) the following: ill health or other personal challenges that arise during a term and changes in the requirements of an ongoing job. +Further information on Academic Concession can be found under Policies and Regulation in the [UBC Academic Calendar](https://vancouver.calendar.ubc.ca/campus-wide-policies-and-regulations/academic-concession). + +## Copyright Disclaimer + +Diagrams and figures included in lecture presentations adhere to [Copyright Guidelines for UBC Faculty, Staff and Students](https://copyright.ubc.ca/requirements/copyright-guidelines/) and [UBC Fair Dealing Requirements for Faculty and Staff](https://copyright.ubc.ca/requirements/fair-dealing/). +Some of these figures and images are subject to copyright and will not be posted to Canvas. +All material uploaded to Canvas that contain diagrams and figures are used with permission of the publisher; are in the public domain; are licensed by Creative Commons; meet the permitted terms of use of UBC’s library license agreements for electronic items; and/or adhere to the UBC Fair Dealing Requirements for Faculty and Staff. +Access to the Canvas course site is limited to students currently registered in this course. +Under no circumstance are students permitted to provide any other person with means to access this material. +Anyone violating these restrictions may be subject to legal action. +Permission to electronically record any course materials must be granted by the instructor. +Distribution of this material to a third party is forbidden. + +## Grievances and Complaints Procedures + +A student who has a complaint related to this course should attempt to resolve the matter with the instructor first. +Students may also talk to other members of the teaching team (TAs, course coordinators, co-instructors) if they do not feel, for whatever reason, that they can directly approach their own instructor. + + +## Academic Integrity + +The academic enterprise is founded on honesty, civility, and integrity. +As members of this enterprise, all students are expected to know, understand, and follow the codes of conduct regarding academic integrity. +At the most basic level, this means submitting only original work done by you and acknowledging all sources of information or ideas and attributing them to others as required. +This also means you should not cheat, copy, or mislead others about what is your work. +Violations of academic integrity (i.e., misconduct) lead to the breakdown of the academic enterprise, and therefore serious consequences arise and harsh sanctions are imposed. +For example, incidences of plagiarism or cheating may result in a mark of zero on the assignment or exam and more serious consequences may apply if the matter is referred to the President’s Advisory Committee on Student Discipline. +Careful records are kept in order to monitor and prevent recurrences. + +A more detailed description of academic integrity, including the University’s policies and procedures, may be found on the [Academic Integrity Website](https://academicintegrity.ubc.ca/about-academic-integrity/) + +If you have any questions about how academic integrity applies to this course, please consult with your professor. + +## Grading Practices + +Faculties, departments, and schools reserve the right to scale grades in order to maintain equity among sections and conformity to University, faculty, department, or school norms. +Students should therefore note that an unofficial grade given by an instructor might be changed by the faculty, department, or school. +[Grades](https://vancouver.calendar.ubc.ca/campus-wide-policies-and-regulations/grading-practices/introduction) are not official until they appear on a student's academic record. +If you have any questions about how academic integrity applies to this course, please consult with your professor. + +## Disability Assistance + +The Centre for Accessibility (CFA) ensures educational equity for students with disabilities, injuries or illness. +If you are disabled, have an injury or illness and require academic accommodations to meet the course objectives, [visit the CFA website](https://students.ubc.ca/about-student-services/centre-for-accessibility) for more information or contact the CFA directly at: [info.accessibility@ubc.ca](mailto:info.accessibility@ubc.ca). + +## Equity, Human Rights, Discrimination and Harassment + +UBC is a place where every student, staff and faculty member should be able to study and work in an environment that is free from human rights based discrimination and harassment. +If you require assistance related to an issue of equity, discrimination or harassment, please contact the [Equity Office](https://equity.ubc.ca) or email ([info@equity.ubc.ca](mailto:info@equity.ubc.ca)), your administrative head of unit, and/or your unit’s equity representative. + +## Health & Wellbeing + +At UBC health services to students are provided by [Health and Wellbeing](https://students.ubc.ca/health). +Nurses, physicians and counsellors provide health care and counselling related to physical health, emotional/mental health and sexual/reproductive health concerns. +As well, health promotion, education and research activities are provided to the campus community. +If you require assistance with your health, please contact [Health and Wellbeing](https://students.ubc.ca/health) in person (UBC Life Building, Room 1400), or by phone (604.822.8450) for more information or to book an appointment. + +## Sexual Violence Prevention and Response Office (SVPRO) + +[SVPRO](https://svpro.ubc.ca) is a safe and confidential place for UBC students, staff and faculty who have experienced sexual violence regardless of when or where it took place. +Just want to talk? We are here to listen and help you explore your options. We can help you find a safe place to stay, explain your reporting options (UBC or police), accompany you to the hospital, or support you with academic accommodations. +You have the right to choose what happens next, and we believe you. +We support your decision, whatever you decide. +Visit [svpro.ubc.ca](https://svpro.ubc.ca), email them at [svpro.vancouver@ubc.ca](mailto:svpro.vancouver@ubc.ca), or call us at 604.822.1588. + +## UBC Investigations Office (IO) + +The UBC Investigations Office (IO) responds to formal reports of sexual misconduct and discrimination involving UBC students, faculty, and staff through investigations and alternative resolution processes. +If you or someone you know has experienced sexual assault or some other form of sexual misconduct by a UBC community member and you want the UBC Investigations Office (IO) at UBC to investigate, please contact the IO. +Investigations are conducted in a trauma informed, confidential and respectful manner in accordance with the principles of procedural fairness. +You can report your experience directly to the IO via a [secure webform here](https://ubc.ca1.qualtrics.com/jfe/form/SV_8oFgTWeLsNiO9F4) or by calling 604.827.2060 or online by visiting [io.ubc.ca](https://io.ubc.ca). + +## SAFEWALK + +You do not have to walk alone on campus. +If you feel unsafe walking alone on campus after dark, or if you are not too sure how to get somewhere on campus, then Safewalk can accompany you to your destination. + +Call Safewalk at 604.822.5355 during their opening hours from 8:00 PM – 2:00 AM. + +For more information, [visit our website](https://www.ams.ubc.ca/support-services/student-services/safewalk/) or download the [UBC SAFE app](https://security.ubc.ca/home/safety-prevention-resources/ubc-safe-app/) on iOS and Android devices. \ No newline at end of file diff --git a/about/syllabus_bits/schedule.md b/about/syllabus_bits/schedule.md new file mode 100644 index 0000000..9c53b0b --- /dev/null +++ b/about/syllabus_bits/schedule.md @@ -0,0 +1,18 @@ +This is the tentative plan for {{ COURSE_CODE }} this term. +Things may change depending on many factors so this is subject to change. + +| Wk | Date | Topic | Speaker | Lab | +|----|---------|-----------------------------------|---------|--------| +| 1 | May 11 | HTML/CSS/Javascript | Ian | Lab 1 | +| 2 | May 18 | No Class Meeting | - | Lab 2 | +| 3 | May 25 | Front End: React & Redux | TBD | Lab 3 | +| 4 | June 1 | No Class Meeting | - | Lab 4 | +| 5 | June 8 | Back End: NodeJS & Express | TBD | Lab 5 | +| 6 | June 15 | No Class Meeting | - | Lab 6 | +| 7 | June 22 | NoSQL with MongoDB | TBD | - | +| 8 | June 29 | No Class Meeting | - | - | +| 9 | July 6 | Release Engineering | TBD | Lab 7 | +| 10 | July 13 | No Class Meeting | - | Lab 8 | +| 11 | July 20 | Portfolio Building and Networking | TBD | Lab 9 | +| 12 | July 27 | No Class Meeting | - | Lab 10 | +| 13 | Aug 3 | Final Showcase! | N/A | - | \ No newline at end of file diff --git a/about/syllabus_bits/teaching_team.md b/about/syllabus_bits/teaching_team.md new file mode 100644 index 0000000..cfc1f99 --- /dev/null +++ b/about/syllabus_bits/teaching_team.md @@ -0,0 +1,6 @@ +| Team Member | Pronounce as | Contact | Office Hour | +|------------------------------|--------------------|------------------|------------------------------------------------------------------------------------------------------------------------| +| {{ INSTRUCTOR }}; Instructor | {{ PRONOUNCE }} | {{ FORUM_LINK }} | Wednesdays 12:30 - 2:30 PM - ICCS 253 or [Zoom](https://ubc.zoom.us/j/6552557192?pwd=SGthMW10cTNBTVpaYitJZ0RMWkdmdz09) | +| {{ TA3 }} | {{ TA3pronounce }} | {{ FORUM_LINK }} | [Mondays 1:30-2:30 PM in X339 and on Zoom](https://ubc.zoom.us/j/8465268502?pwd=U2ZpWWVkNG1JS2E5UzNvOEZZRHFyZz09) | +| {{ TA2 }} | {{ TA2pronounce }} | {{ FORUM_LINK }} | [Thursdays 1-2 PM on Zoom](https://ubc.zoom.us/s/62998255720) | +| {{ TA1 }} | {{ TA1pronounce }} | {{ FORUM_LINK }} | Fridays 12-1 PM - ICCS X337 [or on Zoom](https://ubc.zoom.us/s/61966832541) | \ No newline at end of file diff --git a/about/unsyllabus.md b/about/unsyllabus.md new file mode 100644 index 0000000..879cde0 --- /dev/null +++ b/about/unsyllabus.md @@ -0,0 +1,178 @@ +![](../images/header.jpg) + +![](../images/UBC_CS.png) + +(unsyllabus)= +# Unsyllabus + + + +```{figure} ../images/construction.jpeg +--- +width: 750px +name: Under Construction. +--- +This course website is currently under construction. It will continue to be updated and will be released closer to the course start date. [Photo by Mabel Amber from Pexels](https://www.pexels.com/photo/traffic-red-blue-sign-117602/). +``` + + + + +(acknowledgements)= +## Acknowledgements + +```{include} unsyllabus_bits/acknowledgements.md +``` + + + +(unsyllabus_land-acknowledgement)= +## Land Acknowledgement + +```{include} syllabus_bits/land_acknowledgement.md +``` + +(references)= +## References + +```{bibliography} +:style: unsrt +``` \ No newline at end of file diff --git a/about/unsyllabus_bits/academic_integrity.md b/about/unsyllabus_bits/academic_integrity.md new file mode 100644 index 0000000..aa3a254 --- /dev/null +++ b/about/unsyllabus_bits/academic_integrity.md @@ -0,0 +1,52 @@ +### How do I go through this course with integrity? + +I want to be proud of your work in this course, and I want YOU to be proud of yourself as well! +That cannot happen if you make unethical decisions, including (but not limited) to cheating or plagiarism. +According to the scientific literature, the most common reasons students cheat are: + +- Fear of failure and life consequences +- Peer pressure, including an inability to say no to help others cheat +- Perceived societal acceptance of cheating (Lance Armstrong, Barry Bonds, Enron, Wall Street & the The Big Short) +- Desire for success without the time/desire to put in the work needed +- Strict deadlines and due-dates +- Requirement from instructors to memorize facts, figures, equations, etc... +- High-stakes exams with no recompense for "having a bad day" +- Peers cheating with no consequences or penalties +- Unclear expectations on what constitutes academic dishonesty +- Inadequate support from instructor and teaching team + +Though I sympathize with students and the stresses of your busy lives - in my opinion, there is no good reason to cheat. +I have tried extremely hard to make this course focused on learning rather than grading, and where grading is needed, to have policies that are as student-friendly as possible. +In particular, I hope (and expect) that the following features of the course should eliminate your temptation to cheat or plagiarize: + +- {{ GRACE_PERIOD }} grace-period on all due dates. +- Long testing window so you can start the tests whenever you're comfortable. +- Weekly learning logs, homework and reading reflections to make you think about your learning ([metacognition](https://cft.vanderbilt.edu/guides-sub-pages/metacognition/)). + +- No high-stakes exams (the single largest assessment item is the final exam). + +- Plenty of TA and instructor student hours and several outside of normal business hours. +- Class website that outlines exactly what you should do when to help you manage your time. +- Tonnes of supplemental materials including other instructional videos in case you want a different perspective. +- Weekly prompt to accept the integrity pledge to keep you accountable. +- A true willingness from the instructor (me) to help you learn and succeed in this course! + +With these features, and several other little things, I sincerely hope that you will consider completing this course with maximum integrity so that you never have to feel guilty, ashamed, or disappointed in yourself and your actions! + +A more detailed description of academic integrity, including the University’s policies and procedures, may be found in the [UBC Academic Calendar](https://vancouver.calendar.ubc.ca/campus-wide-policies-and-regulations/student-conduct-and-discipline/discipline-academic-misconduct). + +### What is considered academic dishonesty in this course? + +To make it even easier for you to decide what isn't allowed, below is a list of things that I **definitely** consider to be academic dishonesty: + +- Asking others for their work in the course (whether question by question, or all at once) +- Sending others your work in the course +- Doing tests collaboratively (tests **must** be done by yourself and alone) +- Sending others your test questions and/or answers +- Sharing any course material onto Chegg, Course Hero, Slader, or other similar sites +- Searching for solutions to course material on Chegg, Course Hero, Slader, or other similar sites +- Blindly googling the question in hopes of finding someone who had a similar question and then copying their answer + - Note, googling to find resources to understand specific concepts or general ideas is highly encouraged! +- Having a tutor/friend/nemesis complete and submit your work for you +- Copying and pasting code, equations, text explanations, prose, etc... without attribution +- Manipulating the learning platforms we use to reverse engineer the randomization algorithms, hacking the timer functionality, or other similar technical [malfeasance](https://dictionary.cambridge.org/dictionary/english/malfeasance). diff --git a/about/unsyllabus_bits/acknowledgements.md b/about/unsyllabus_bits/acknowledgements.md new file mode 100644 index 0000000..537e479 --- /dev/null +++ b/about/unsyllabus_bits/acknowledgements.md @@ -0,0 +1,16 @@ +Credit for the creation of this course goes largely to contributions by: + +- Danya Karras, UBC Alum, D2L Software Engineering Manager +- Ian McLean, UBC Alum, D2L Sr. dev +- Stephanie Mah, UBC Alum, Produce8 Software Developer +- Steve Wolfman, UBC Professor of Teaching + + + + + + + +- [Header image - Photo by Jem Sanchez from Pexels](https://www.pexels.com/photo/city-lights-during-sunset-695798/) + +- [Course Logo - Photo by Paul Chadeisson on ArtStation](https://www.artstation.com/artwork/48WOol) diff --git a/about/unsyllabus_bits/changes.md b/about/unsyllabus_bits/changes.md new file mode 100644 index 0000000..244e042 --- /dev/null +++ b/about/unsyllabus_bits/changes.md @@ -0,0 +1,9 @@ +In this section, I will outline any changes that have been made to the unsyllabus as we go through the course. +We will do our best to follow the plan outlined in this unsyllabus, but in case things go south, I will need to make adjustments to the contents and the schedule. + +Any major changes to the syllabus (this page) will be documented here, as well as the date the change was made. + +| Change Date | Summary | Rationale | +|--------------|-------------------------------------------------------------------------------------------------------|-----------| +| Jan 18, 2024 | Removed left-over language about assessments being open-book, open-web now that we are using the CBTF | Unfortunately, the CBTF does not yet allow open-book and open-web assessments so our Examlets and final exam need to be closed book with no access to web resources. This was always the intention, and there was one instance that I copied from another course (which doesn't use the CBTF!). Apologies for the oversight. | +| Jan 22, 2024 | Removed left-over language about "bonus tests" since we're not doing that this year. | We will have a slightly different scheme for recovering lost points to be released later in the term. | \ No newline at end of file diff --git a/about/unsyllabus_bits/course_tools.md b/about/unsyllabus_bits/course_tools.md new file mode 100644 index 0000000..0ca1237 --- /dev/null +++ b/about/unsyllabus_bits/course_tools.md @@ -0,0 +1,22 @@ +```{warning} +I will be the first to acknowledge that my courses are usually heavily reliant on learning technologies. +I strongly believe that learning technologies are essential (for me) to give you my students a good experience in the course. +Many times during the course you may be frustrated why we need to use so many different tools, and why there isn't one tool that does everything. +Believe me, this frustrates me too (particularly because each of your instructors will be using different tools depending on their needs), and is something that I'm working on improving. +At the moment, the reality is that many learning technologies often only do *one thing* very well. +This of course means that other functionalities take a back-seat and exist merely to check a box on their marketing website (just to say they have the feature). + +**In all of my courses, before selecting a learning technology, I do a very careful scan of the landscape, weigh the pros and cons, consider the privacy implications, the convenience aspects, and then select the ones that I believe will best support my teaching goals at minimal inconvenience to students. In general, I also use tools that are fun to use!** + +I hope you will be patient with all the tools used in this course, I hope I can demonstrate value to you by using them in our course. +If you have any feedback about my usage of the tools, I'd be happy to [get your (anonymous) feedback](page_feedback) and though it may not always be possible to make changes mid-semester, I will certainly keep your feedback in mind as I plan the next iteration of this course. +``` + +All tools used in the course will be used in a [FIPPA-compliant](https://universitycounsel.ubc.ca/subject-areas/access-and-privacy-general/access-to-information/about-fippa/) manner, with your privacy top of mind. +New tools may be added to the course as the need arises, and I will update this section with the appropriate information and make an announcement if a new tool is added midway through a course. + +There is no cost to the student for any of the tools used in this course. + +```{tip} +Even though the tools above are required for this course, if you have a moral or legal objection to my use of these tools, please do reach out to me and we can likely find an acceptable accommodation. +``` \ No newline at end of file diff --git a/about/unsyllabus_bits/doing_well_cpsc.md b/about/unsyllabus_bits/doing_well_cpsc.md new file mode 100644 index 0000000..ace600e --- /dev/null +++ b/about/unsyllabus_bits/doing_well_cpsc.md @@ -0,0 +1,44 @@ +To prepare yourselves for this course, remember that: + +1. Learning is a contact sport. +2. Memorizing is not learning. +3. Understanding is learning, and understanding should be your goal (not grades). +4. We’ll do lots of tests. + +And some ingredients for your success: + +1. Plan. +1. Prepare. +1. Engage. +1. Practice. +1. Collaborate. +1. Do not be fooled by familiarity of the material. + +```{important} +These guidelines were adapted from [Dr. Simon Bates' Physics 117 course from UBCV](https://sites.google.com/site/simonpbates/home?authuser=0). +``` + +### ... but I've never been good at computer science! + +That's okay! +You're still more than welcome in this course. +I will do everything I can (within reason) to still make the course accessible to you. +This course is designed with your success in mind. +There are multiple opportunities for you to learn from your mistakes and improve your grades in nearly every aspect of the course. +In my opinion, the best learning happens when folks are given the opportunity to make mistakes so they get over their fear of trying new things! + +To summarize, if you've never been "good" at computers, come into the course with a healthy attitude, a desire to work for your success, and I have no doubt you will be successful in this course. +If you ever want to talk about the course, or have any feedback you want to give me, do not hesitate to reach out to me! + +### ... but I don't even like computers! + +Believe it or not, I have no expectation that every student that takes my course will have an undying passion for the subject. +Some of you may be forced to take this course by your programs, faculties, career interests, etc... +Sometimes we all have to take courses that we think we don't like, or enjoy. +That's fine! +No judgement from me, you are more than welcome in this course. +I just ask that you not make any snap judgements about the class, the material, the instructor (me), or the teaching team. +Whatever your motivations are for taking this course, give us a chance, maybe you don't HAVE TO be miserable taking this course! +You might even enjoy the feeling of community and camaraderie that develops over the course of the semester :-). + +I hope you're not miserable, if you do feel miserable, come talk to me - maybe I can help you see the light at the end of tunnel? \ No newline at end of file diff --git a/about/unsyllabus_bits/doing_well_physics.md b/about/unsyllabus_bits/doing_well_physics.md new file mode 100644 index 0000000..ab2d66e --- /dev/null +++ b/about/unsyllabus_bits/doing_well_physics.md @@ -0,0 +1,46 @@ +For full details, please see the page {ref}`page_doing_well`. + +To whet your appetite on what you'll read there, here are some guidelines on preparing yourselves for this course: + +1. Learning is a contact sport. +2. Memorizing is not learning. +3. Understanding is learning and understanding should be your goal. +4. We'll do lots of tests. + +And some ingredients for your success: + +1. Plan. +1. Prepare. +1. Engage. +1. Practice. +1. Collaborate. +1. Do not be fooled by familiarity of the material. +1. Practice Math. + +### ... but I've never been good at physics or math! + +That's okay! +You're still more than welcome in this course. +I will do everything I can (within reason) to still make the course accessible to you. +This course is designed with your success in mind. +There are multiple opportunities for you to learn from your mistakes and improve your grades in nearly every aspect of the course. +In my opinion, the best learning happens when folks are given the opportunity to make mistakes so they get over their fear of trying something! +At the beginning of the term, we will all do a Math Diagnostic (not for marks) to check if you have the required math background for this course. +If you do not, I have some supplemental material for you to catch up. +My expectation is that you'll complete the exercises and review the supplemental material in the first couple of weeks. + +To summarize, if you've never been "good" at physics or math, come into the course with a healthy attitude, a desire to work for your success, and I have no doubt you will be successful in this course. +If you ever want to talk about the course, or have any feedback you want to give me, do not hesitate to reach out to me! + +### ... but I don't even like physics or math! + +Believe it or not, I have no expectation that every student that takes my course will have an undying passion for the subject. +Some of you may be forced to take this course by your programs, faculties, career interests, etc... +Sometimes we all have to take courses that we think we don't like, or enjoy. +That's fine! +No judgement from me, you are more than welcome in this course. +I just ask that you not make any snap judgements about the class, the material, the instructor (me), or the teaching team. +Whatever your motivations are for taking this course, give us a chance, maybe you don't HAVE TO be miserable taking this course! +You might even enjoy the feeling of community and camaraderie that develops over the course of the semester :-). + +I hope you're not miserable, if you do feel miserable, come talk to me - maybe I can help you see the light at the end of tunnel? \ No newline at end of file diff --git a/about/unsyllabus_bits/getting_help.md b/about/unsyllabus_bits/getting_help.md new file mode 100644 index 0000000..7577ed3 --- /dev/null +++ b/about/unsyllabus_bits/getting_help.md @@ -0,0 +1,19 @@ +The best way to get personalized help in this course is to attend the "Student Hours" we have scheduled for this course. +They are all done on Zoom and this is time that the instructor and TAs have set aside to help YOU personally, 1 on 1! +I understand it might feel intimidating to come to Student Hours, but we don't bite! +We would love to hear about you, what your interests are, and if you have any career advice. +If nobody comes to the Student Hours, we end up sitting in a Zoom room all by ourselves, all alone, and sad. + +A few other notes: + +- We will be using {{ FORUM_LINK }} for Announcements in this course. +- For **all** course-related questions you can reach out to the teaching team including instructors and TAs via {{ FORUM_LINK }}. +- You are encouraged to post questions publicly whenever possible so others can benefit. For private and personal issues, you can send private messages on {{ FORUM_LINK }}. +- Any student may visit the student hour for any member of the teaching team (TA or instructor)! In other words, you can go to the student hour of ANY TA, not just the one whose lab/tutorial you are registered in. + +### Why should I take {{ COURSE_CODE }}? + +```{include} syllabus_bits/course_teaser.md +``` + +
\ No newline at end of file diff --git a/about/unsyllabus_bits/grading_practices_detailed.md b/about/unsyllabus_bits/grading_practices_detailed.md new file mode 100644 index 0000000..cd1e65e --- /dev/null +++ b/about/unsyllabus_bits/grading_practices_detailed.md @@ -0,0 +1,22 @@ +The grading scheme for this course is: + +| Item | Weight | Due date(s) | +|----------------------|-----------------|-------------------| +| Learning Logs | 5% (10 x 0.5%) | Saturdays at 6 PM | +| Problems of the Week | 25% (10 x 2.5%) | Fridays at 6 PM | +| Labs | 5% (10 x 0.5%) | Fridays at 6 PM | +| Programming Projects | 15% (3 x 5%) | Three in the term | +| Tests (Examlets) | 30% (6 x 5%) | \~ Bi-weekly | +| Final Exam | 20% | TBD | + +There will be 6 tests in this course in an (approximately) bi-weekly schedule. + + +```{attention} +All due dates in this course have an automatic 48 hour grace period after the due dates listed above. +Any submissions submitted past the grace period will not be graded (with some exceptions). +``` + +```{note} +Please refer to [this page](https://students.ubc.ca/enrolment/exams/exam-clashes-hardships-cancellations) for details on exam clashes, hardships, and cancellations. +``` \ No newline at end of file diff --git a/about/unsyllabus_bits/important_details.md b/about/unsyllabus_bits/important_details.md new file mode 100644 index 0000000..699d82e --- /dev/null +++ b/about/unsyllabus_bits/important_details.md @@ -0,0 +1,17 @@ + +| Name | Description | +|------------|---------------------------------| +| Course | {{ COURSE_CODE }} | +| Term | {{ TERM }} | +| Instructor | {{ INSTRUCTOR }} | +| Lectures | {{ MEETING_TIMES }}: {{ ROOM }} | +| Mode of Delivery | In-person (All course activities and assessments, including the Final Exam, will be conducted in-person) | +| Student Hours | To get live 1 on 1 help in the course, use {{ ZOOM_LINK.replace('CANVAS_ID',CANVAS_ID) }} at various times (see below for schedule). | +| Canvas URL | {{ CANVAS_LINK.replace('CANVAS_ID',CANVAS_ID) }} | +| Course Discussion | To ask any course-related questions, use private (personal, not useful for anyone else) or public (helpful for other) messages on {{ FORUM_LINK }} | + +You can find all the important term dates in the [UBC Academic Calendar](https://vancouver.calendar.ubc.ca/dates-and-due dates). + +```{warning} +If there is a lab and/or tutorial listed on the SSC for this course, You **must** register for all course elements without conflicts, otherwise the department will remove you from the course! There are usually lab or tutorial exemptions for some students (i.e. those repeating the course) and instructions for that will be in this syllabus. +``` diff --git a/about/unsyllabus_bits/main_nav.md b/about/unsyllabus_bits/main_nav.md new file mode 100644 index 0000000..d6bb6b7 --- /dev/null +++ b/about/unsyllabus_bits/main_nav.md @@ -0,0 +1,106 @@ +::::{grid} 1 1 2 3 +:class-container: text-center +:gutter: 3 + +:::{grid-item-card} +:link: contact-us +:link-type: ref +:class-header: sd-bg-primary sd-text-white + +Teaching Team ✏️ +^^^ + +Information about the teaching team and how to contact us. +::: + +:::{grid-item-card} +:link: schedule +:link-type: ref +:class-header: sd-bg-dark sd-text-white + +Course Schedule 🗓 +^^^ + +A table of course topics and a week-by-week plan of what we intend to cover. + +::: + +:::{grid-item-card} +:link: doing-well +:link-type: ref +:class-header: sd-bg-success sd-text-white + +Doing Well 😊 +^^^ + +Strategies and tips on how to do well in this course. + +::: + +:::{grid-item-card} +:link: getting-help +:link-type: ref +:class-header: sd-bg-warning + +Getting Help ❤️‍🩹 +^^^ + +Learn how to get help and get support if you're struggling, academically or otherwise. +::: + +:::{grid-item-card} +:link: evaluation +:link-type: ref +:class-header: sd-bg-primary sd-text-white + +Evaluation ✅ +^^^ + +Information about the grading system and evaluation scheme for this course. +::: + +:::{grid-item-card} +:link: philosophy +:link-type: ref +:class-header: sd-bg-light + +Teaching Philosophy 🧙‍♂️ +^^^ + +How this course will be taught and how humans learn (you may be surprised!). +::: + +:::{grid-item-card} +:link: changes +:link-type: ref +:class-header: sd-bg-danger sd-text-white + +Changes ✍️ +^^^ + +List of changes made to the Unsyllabus since the start of term, and a rationale. +::: + +:::{grid-item-card} +:link: academic-integrity +:link-type: ref +:class-header: sd-bg-info sd-text-white + +Honesty & Integrity 😇 +^^^ + +Completing this course with honesty and integrity. Examples of things you can and should not not do. +::: + +:::{grid-item-card} +:link: missed-things +:link-type: ref +:class-header: sd-bg-secondary sd-text-white + +Special Days 🤧💝🕌🥳 +^^^ + +What to do if you have to miss things because of special days (including getting sick). +::: + +:::: \ No newline at end of file diff --git a/about/unsyllabus_bits/missed_things.md b/about/unsyllabus_bits/missed_things.md new file mode 100644 index 0000000..208dc40 --- /dev/null +++ b/about/unsyllabus_bits/missed_things.md @@ -0,0 +1,57 @@ +### What if I miss labs, tests, or the exam due to an illness, health, or other personal situations? + +Normally, most due dates in this course have a generous grace period. +If you require an extension beyond the grace period, please contact the instructor on {{ FORUM_LINK }} (ideally before the deadline passes) to discuss your options. + +Students who, because of unforeseen events, are absent during the term and are unable to complete tests or other graded work, should normally discuss with their instructors how they can make up for missed work. +If ill health is an issue, students are encouraged to seek attention from a health professional. +Campus Health and Counselling will normally provide documentation only to students who have been seen previously at these offices for treatment or counselling specific to conditions associated with their academic difficulties. + +```{tip} +If you miss a course component due to an illness, health, or other personal situation, please reach out to me as soon as you are comfortable, and I'll work with you to get you back on track. +``` + +### What if I have dependents that rely on me for care and unpredictable emergencies may arise? + +Let's talk, send me a private message and we can discuss it. +I do not necessarily need to know all the personal details, just a high-level summary of your situation and what you think an ideal solution would be. + +I'm sure we will come to some agreement, generally the earlier you let me know of any special circumstances or accommodation, the more I'll be able to do for you! + +### What if I have to miss a deadline because of a wedding, birthday, funeral, religious holiday, or personal event ? + +No problem! There's not even any need to tell me, or ask for permission to miss due dates. +The course is designed to give you maximum flexibility: + +- Every deadline has a {{ GRACE_PERIOD }} grace period that is automatically applied. +- There is no late penalty if you use the grace period +- You can use the grace period an unlimited amount of time in the course (though if it happens every week and for every assignment, I might check in with you and gently encourage you not to leave things to the last minute) + + + +If you miss a deadline by more than the grace period, the general course policy is that you will not be able to get full credit for it, and in many cases, may even get a 0 for it. +In the cases of Tests, it is not possible to get partial credit, or complete it at times other than within the scheduled windows. +In some cases, I reserve the right to grant an extension or make alternate accommodations as needed. + +### What should I do if I need accommodations to be successful in this course? + +Accommodations are intended to remove barriers experienced by individuals with disabilities. +As a matter of principle, UBC is committed to promoting human rights, equity and diversity, and it also has a legal duty under the BC Human Rights Code to make its goods and services available in a manner that does not discriminate. +[Policy 73](https://universitycounsel.ubc.ca/files/2019/02/policy73.pdf) (Accommodation for Students with Disabilities) sets out principles and processes governing the accommodation of students with disabilities. + +All accommodations for this course are handled through the [Centre for Accessibility](https://students.ubc.ca/about-student-services/centre-for-accessibility) and I encourage you to contact them to book an appointment. + +### Compassion + +Overall, my philosophy is that I think we could all use some extra compassion and humanity wherever and whenever it's possible. +If you're going through something that is affecting you (in the course or otherwise), you are always welcome to come and talk to me about it. +If I am not able to help you myself, then I can probably direct you to the right person or resource on campus. +If you need extra help, or extra time to deal with something you're going through, just ask. +You will *never* owe me an explanation about your physical health, mental health, or those of your family members, friends, etc... I will believe you, and I will trust you. +I will not judge you, nor think any less of you. +I will do everything in my power to work out something that is both reasonable and fair. +This, I promise! \ No newline at end of file diff --git a/about/unsyllabus_bits/teaching_philosophy.md b/about/unsyllabus_bits/teaching_philosophy.md new file mode 100644 index 0000000..5313431 --- /dev/null +++ b/about/unsyllabus_bits/teaching_philosophy.md @@ -0,0 +1,35 @@ +For a detailed description of my teaching philosophy and values (including a list of references and citations), you can [read it here](https://firas.moosvi.com/cv/teaching-philosophy/). +Here are the key principles I intend to apply in this class: + +1. Student learning is vastly improved through active learning +1. Learning technologies must be leveraged to scale instructor effort across multiple classes. +1. Inter-disciplinarity is the future of education. +1. Effective teaching is inclusive teaching. + +### How will this course be taught ? + +This course will be taught as a [Blended Learning classroom](https://en.wikipedia.org/wiki/Blended_learning) where some elements of a [flipped classroom](https://www.youtube-nocookie.com/embed/BCIxikOq73Q) will be mixed with a more traditional coding classroom with live demos, clicker questions, and worksheets. +Briefly, this requires students to watch videos and engage with the assigned reading prior to the classroom meeting (knowledge transfer). +During the class meeting, the instructor guides students through clicker questions, worksheet problems, and other activities to help the students make sense of the material (sense-making). +See {numref}`masterymodel1` for a mental model of how learning works {cite}`Ambrose2010`. + +```{figure} ../images/masterymodel1.png +--- +width: 750px +name: masterymodel1 +--- +To develop mastery in a concept, students must first acquire the necessary skills, then practice integrating them, and finally know when to apply what they have learned. This figure was adapted from Figure 4.1 of the book "How Learning Works". +The terms "knowledge transfer" and "sense-making" applied in this context is generally attributed to [Dr. Eric Mazur](https://mazur.harvard.edu/files/mazur/files/flip_your_course_online_07.pdf). +``` + +### What does this mean in practical terms? + +{numref}`masterymodel2` shows a handy table to help guide you and organize your learning in this course: + +```{figure} ../images/masterymodel2.png +--- +height: 500px +name: masterymodel2 +--- +This table describes how I think each course activity should be classified between knowledge transfer and sense-making. +``` diff --git a/about/unsyllabus_bits/tools/canvas.md b/about/unsyllabus_bits/tools/canvas.md new file mode 100644 index 0000000..e69de29 diff --git a/about/unsyllabus_bits/tools/ed_discussion.md b/about/unsyllabus_bits/tools/ed_discussion.md new file mode 100644 index 0000000..da347f7 --- /dev/null +++ b/about/unsyllabus_bits/tools/ed_discussion.md @@ -0,0 +1,13 @@ +### Ed Discussion [Required] + +In this course, we will be using {{ FORUM_LINK }} for class discussions. +You will need to sign up for a (free) Ed Discussion account to participate in the discussions for this course. +The system is highly catered to getting you help fast and efficiently from classmates, the TA, and myself. + +```{tip} +In general, please do NOT email questions to the instructor and TAs unless it is a legitimate emergency (or if you cannot access Ed Discussion). If you do this accidentally, it's okay - we will send you an automated response letting you know that emails will not be answered and you should re-post your question on Ed Discussion. +``` + +```{warning} +Data on Ed Discussion is stored on servers outside Canada. When you access this site by clicking on the link through Canvas, you are being transferred to these servers. In order to protect your identity, UBC obfuscates your user ID before it is sent to the site. However, Ed Discussion does require you to create an account on their servers. While Ed Discussion adheres to strict U.S. privacy regulations (FERPA), UBC cannot guarantee security of your private details on servers outside of Canada. Please exercise caution whenever using personal information. You may wish to use a pseudonym to protect your privacy if you have concerns. +``` diff --git a/about/unsyllabus_bits/tools/github.md b/about/unsyllabus_bits/tools/github.md new file mode 100644 index 0000000..4b805fb --- /dev/null +++ b/about/unsyllabus_bits/tools/github.md @@ -0,0 +1,20 @@ +### GitHub [Required] + +Git is a modern and open-source distributed version control system that aims to facilitate collaborative software development, data analysis, and [even writing poetry](https://writerly.dev). +We use Git because it is technically sound, very good at what it does, and is a system where many communities (perhaps uniquely!) have largely converged on a single system (with some exceptions, see below) for version control. +In the [2022 Stack Overflow Developer survey](https://stackoverflow.blog/2023/01/09/beyond-git-the-other-version-control-systems-developers-use/), 93% of respondents reported using Git as their system of choice for version control. + +Git is the underlying system that facilitates distributed work on code bases, and GitHub is one cloud-based provider that hosts Git repositories, and offers useful convenience features to facilitate collaboration between multiple developers (and even single developers). +Of course, there are alternatives to GitHub for hosting Git repositories (similar to how there are various email providers that will host your email like Google, Yahoo, Proton Mail, etc...). +We chose to use GitHub.com mostly because of the existence of GitHub Classroom, which helps instructors with a lot of the logistics of repository management. + +```{warning} +Data on GitHub (typically your course labs, assignments, and projects) is stored on servers outside Canada. When you access this site by clicking on the link through Canvas, you are being transferred to these servers. GitHub does require you to create an account on their servers. **There is no requirement from this course for you to share any personal information on GitHub servers.** UBC cannot guarantee security of your private details on servers outside of Canada. Please exercise caution whenever using your personal information online. You may wish to use a pseudonym account to protect your privacy if you have concerns about this. +``` + +Here is a quick video to show you how to create a GitHub account: + +
+ + +
\ No newline at end of file diff --git a/about/unsyllabus_bits/tools/gradescope.md b/about/unsyllabus_bits/tools/gradescope.md new file mode 100644 index 0000000..c45e51d --- /dev/null +++ b/about/unsyllabus_bits/tools/gradescope.md @@ -0,0 +1,15 @@ +### Link your Canvas account to Gradescope + +On the left sidebar in Canvas, click on Gradescope. + + +You should then be guided through a series of steps to create an account, set a password, and link it to our course. + +This is **very** important for you to do as it'll be our primary mechanism for delivering you feedback in this course. + +```{warning} +Please verify that you do not have duplicate Gradescope accounts, this is more likely to happen when you have used Gradescope in the past with a different emails, though it has been known to happen to students who accidentally created two accounts on initial signup. + +If the email associated with Gradescope is correct, things should be all good. +If not, then you may need to merge multiple accounts together, [see details on how to do that here](https://help.gradescope.com/article/ipjyg27lg5-student-merge-accounts). +``` \ No newline at end of file diff --git a/about/unsyllabus_bits/tools/prairielearn.md b/about/unsyllabus_bits/tools/prairielearn.md new file mode 100644 index 0000000..dde70cc --- /dev/null +++ b/about/unsyllabus_bits/tools/prairielearn.md @@ -0,0 +1,14 @@ +### PrairieLearn + +PrairieLearn is an open source, extensible online assessment platform built on modern web technologies and is available to students at no cost. +This system replaces commerical textbook publisher platforms for homework assignments such as MasteringPhysics, WileyPlus etc. +In the past, instructors were forced to use these expensive options and pass these costs on to the students, to the tune of $60/student per course with just a temporary "subscription" to a textbook. +Today, thanks to the emergence of high-quality open-education resources (OERs), student advocacy (see the [UBC Senate policy](https://vancouver.calendar.ubc.ca/campus-wide-policies-and-regulations/academic-assessment/fee-based-digital-learning-tools-used-assessment)) and institutional support (the [TLEF](https://tlef.ubc.ca/funded-proposals/?filter_43=&filter_42=&filter_15=&filter_34=&gv_search=PrairieLearn&mode=all) and the [ALT-2040](https://alt-2040.ok.ubc.ca/funded-projects/) projects), and free and open source software (FOSS) we have alternatives. + +In the first week of class, we will do a demo of the PrairieLearn platform together, but if you'd like to get started, you can [join the course and do the first assignment by clicking here](https://ca.prairielearn.com/pl/course_instance/2439/assessment/18407). + +```{important} +You should login by clicking "Sign in with UBC" and provide your UBC CWL credentials: + +Login options for PrarieLearn, arrows are pointing to 'Sign in with UBC' +``` diff --git a/about/unsyllabus_bits/tools/slido.md b/about/unsyllabus_bits/tools/slido.md new file mode 100644 index 0000000..e69de29 diff --git a/about/unsyllabus_bits/why_syllabus_unsyllabus.md b/about/unsyllabus_bits/why_syllabus_unsyllabus.md new file mode 100644 index 0000000..f3893a6 --- /dev/null +++ b/about/unsyllabus_bits/why_syllabus_unsyllabus.md @@ -0,0 +1,43 @@ +Traditionally, there has been a culture at most higher education institutions for every course to have a document that sets expectation for how the course will be conducted, what students will be expected to do, and what they will learn in the course. +The purpose of that document was for the instructor to communicate "what the course will be about" to students so they know what they're getting themselves into. +This document is typically called a "Syllabus" or a "Course Outline". +Over the years however, this document has morphed into something like a contract - a "terms of service" that students implicitly agree to by registering for the class. + +This makes me somewhat uncomfortable as an educator - I don't want to legislate how you learn and what you need to do to learn. +I also don't want there to be an unchangeable legal document governing the interactions between an instructor and a student. +What I do want is to give you suggestions and guidelines supported by my personal experience as well as the latest literature on teaching and learning. + +That being said, perhaps there are some advantages to having some elements of a course codified in a "legal document" - the "Syllabus". +For instance, the instructor for the course, the calendar course entry, the term dates, the final exam period, the passing criteria, how to file a grievance or complaint, and your responsibilities to uphold UBC's commitment to equity, diversity, and inclusion. +The items above are indeed permanent and unchanging, and deserve to be in the syllabus. + +Other things, such as what you will learn, how and when you will do it are more flexible and fluid. +For that, we have this unsyllabus. + +### What is the Unsyllabus? + +In contrast to the syllabus, the unsyllabus is not a legal document. Instead, it is a *living document* that serves students and adjusts to their needs and feedback. +Dr. John Warmer describes this best [in his article, "A syllabus is not a contract"](https://www.insidehighered.com/blogs/just-visiting/syllabus-not-contract): + +> ... this [un]syllabus is not a contract, it is a living document which reflects the experiences, emotions, philosophies, and goals I bring to a particular course. + +and also: + +> An [un]syllabus as a plan is a lot like an itinerary before a trip. +> There’s some definite highlights we need to hit, but if something that seems cool and worth doing crops up unexpectedly, we need to seize that opportunity in the moment. +> If something really bad happens (the equivalent of a norovirus breakout on a cruise ship) we may need to abandon something previously scheduled entirely. + +### Summary + +Having an adaptive syllabus is important to me as it allows me to be responsive to your feedback in a meaningful way. +I invite you to be co-contributors to this unsyllabus, and use the tools provided to add your own annotations, questions, and suggestions on making this syllabus work for you. +At various points in the term, I will invite you to provide feedback on how things are going in the class. +You may use those opportunities (or any other using the anonymous {{ ANON_FEEDBACK }} or {{ FORUM_LINK }}) to propose adjustments to how the class is running for consideration. + +| Document | Status | +|------------|------------------------------------------------------------------------------------------------------------------------------------------| +| Syllabus | University-mandated, like a legal contract and contains university rules about conduct and behaviour; elements will not change. | +| Unsyllabus | Living document, responsive to student feedback and adaptable to circumstances; elements may change, usually to the benefit of students and of learning. | + +```{important} Please note that I have your best interests in mind, and it is highly unlikely that I will ever change the unsyllabus in a way that negatively affects the class, or even individual students. If you believe a change is affecting you negatively, please reach out to me on {{ FORUM_LINK }}, or submit your feedback using the anonymous {{ ANON_FEEDBACK }}. +``` \ No newline at end of file diff --git a/about/unsyllabus_bits/withdrawing.md b/about/unsyllabus_bits/withdrawing.md new file mode 100644 index 0000000..d541265 --- /dev/null +++ b/about/unsyllabus_bits/withdrawing.md @@ -0,0 +1,20 @@ +First of all, I'm sorry you're having trouble and are considering withdrawing from the course! +This is no problem, and I will not be personally offended or upset you need to do this, I encourage you to do what you feel is right for you and your situation. +Below is some information that might be helpful for you in making the decision. + +```{warning} Please note that it is the student's responsibility to check the withdrawal dates as [listed in the UBC Calendar](https://vancouver.calendar.ubc.ca/dates-and-due dates). +``` +| Withdrawal type | Effect on Transcript | Tuition refund | +|------------------------|----------------------|----------------------------------------------------------------------------------------------------| +| Before {{ W_DATE_1 }} | None | 100% refund | +| Before {{ W_DATE_2 }} | W on transcript | [See policy details](https://vancouver.calendar.ubc.ca/fees/tuition-fees/refund-tuition-fees) | +| After {{ W_DATE_3 }} ^ | W on transcript | [See policy details](https://vancouver.calendar.ubc.ca/fees/tuition-fees/refund-tuition-fees) | + +^ Note: Withdrawal after this date cannot happen without additional approvals, see [here](https://vancouver.calendar.ubc.ca/campus-wide-policies-and-regulations/withdrawal/introduction). + +There are factors other than money and your transcript to consider as well, including your mental health, graduation requirements/timelines, [course load requirements](https://students.ubc.ca/enrolment/courses/course-load-guide), eligibility for student loans, bursaries, scholarships etc. +I advise you to [read a list of some considerations](https://science.ubc.ca/students/blog/impact-of-a-w) here and consult with an advisor if you have additional questions. + +```{warning} +International students have additional factors to consider when withdrawing - you are urged to follow-up with an advisor and see the [frequently asked questions here](https://students.ubc.ca/international-student-guide/immigration/taking-time-away-school-international). +``` \ No newline at end of file diff --git a/files/README.md b/files/README.md new file mode 100644 index 0000000..223c94e --- /dev/null +++ b/files/README.md @@ -0,0 +1 @@ +Place anything you want accessible outside of the JB world here, including slides, worksheets, and other "files". diff --git a/getting-started/bits/01_student_email.md b/getting-started/bits/01_student_email.md new file mode 100644 index 0000000..939182e --- /dev/null +++ b/getting-started/bits/01_student_email.md @@ -0,0 +1,29 @@ +```{dropdown} 📧 1. Sign up for a UBC Student Email address! + :class-container: sd-shadow-lg + :color: success + :name: email + +As a student of UBC you are entitled to a free, secure, institutional email address: **@student.ubc.ca**. +But, to claim it, you must first activate it. + +Here are the steps to sign up for a Student Email Address: + +- Sign in to the [CWL myAccount page](https://www.myaccount.ubc.ca/myAccount/login.xhtml) and click on **Activate Student Email** + - You must be registered in a course and in good standing to be eligible for this service +- Check your [UBC Student Email online](https://webmail.student.ubc.ca/) +- Set up your UBC email on your mobile device + - [iOS](https://ubc.service-now.com/kb_view.do?sysparm_article=KB0016885) + - [Android](https://ubc.service-now.com/kb_view.do?sysparm_article=KB0016889) +- Set up your UBC email on your laptop or desktop to send/receive email + - macOS + - Open the "Mail" app on your macOS + - If you've never linked an email account before, it will ask you to add an Account + - If you already have a different account added to your Mail app (for e.g., your gmail account), click on Mail on the top menubar and click "Add Account" + - Choose "Microsoft Exchange" as the account option + - Enter in your email address: @student.ubc.ca + - Enter in your password at the prompt, and it should authenticate + - [Windows](https://ubc.service-now.com/kb_view.do?sysparm_article=KB0016884) + +You should get into the habit of using this email address as much as possible during your career at UBC. +This account will also grant you access to a range of other UBC services including a free license to Microsoft Office and OneDrive. +``` \ No newline at end of file diff --git a/getting-started/bits/02_print.md b/getting-started/bits/02_print.md new file mode 100644 index 0000000..0bf7780 --- /dev/null +++ b/getting-started/bits/02_print.md @@ -0,0 +1,12 @@ +```{dropdown} 🖨 2. Set yourself up to Print on Campus + :class-container: sd-shadow-lg + :color: success + :name: print + +UBC has a super sweet printing process that is fast and convenient! +You can print from anywhere on campus and then go to your closest printer to pick up your documents. +I encourage you to set it up and try it once before things get crazy and you need to print things in a panic. +It's extremely unlikely you'll need to print anything for this course but you'll never know when you need it! + +[Set up your computer to print here.](https://services.library.ubc.ca/computers-technology/copy-print-scan/pay-for-print-students-faculty-staff/) +``` \ No newline at end of file diff --git a/getting-started/bits/03_canvas_login.md b/getting-started/bits/03_canvas_login.md new file mode 100644 index 0000000..1a0c63b --- /dev/null +++ b/getting-started/bits/03_canvas_login.md @@ -0,0 +1,15 @@ +```{dropdown} 1. Log into Canvas + :class-container: sd-shadow-lg + :color: primary + :open: + +Canvas is the go-to platform at UBC. +You can access it by going to: https://canvas.ubc.ca and logging in with your CWL. +I expect you'll find most of your courses to be using the Canvas platform. +All the information and content for this course will be posted on Canvas. + +In my course, the left sidebar is where you will find most things. +It's fairly intuitive, but the Centre for Teaching, Learning, and Technology has created a [Canvas Student Guide](https://lthub.ubc.ca/guides/canvas-student-guide/). + + +``` \ No newline at end of file diff --git a/getting-started/bits/04_github.md b/getting-started/bits/04_github.md new file mode 100644 index 0000000..bff166d --- /dev/null +++ b/getting-started/bits/04_github.md @@ -0,0 +1,14 @@ +```{dropdown} 2. Create an account on GitHub (if you don't already have one) + :class-container: sd-shadow-lg + :color: primary + +In this course, we will be using GitHub for our labs and assignments. +This will be explained later in the first week, for now just create an account (if you do not already have one, you can continue using an existing account). + +Here is a quick video to show you how to create a GitHub account: + +
+ + +
+``` \ No newline at end of file diff --git a/getting-started/bits/05_gradescope.md b/getting-started/bits/05_gradescope.md new file mode 100644 index 0000000..72114a9 --- /dev/null +++ b/getting-started/bits/05_gradescope.md @@ -0,0 +1,13 @@ +```{dropdown} 3. Gradescope + :class-container: sd-shadow-lg + :color: primary + :open: + +On the left sidebar in Canvas, click on Gradescope. +You should then be guided through a series of steps to create an account on **gradescope.ca**, set a password, and link it to our course. +Note that at UBC, we use gradescope**.CA** not gradescope*.com*. + +This is **very** important for you to do as it'll be our primary mechanism for submitting your work, and us delivering you feedback in this course. + + +``` \ No newline at end of file diff --git a/getting-started/bits/06_course_survey.md b/getting-started/bits/06_course_survey.md new file mode 100644 index 0000000..4697f8d --- /dev/null +++ b/getting-started/bits/06_course_survey.md @@ -0,0 +1,12 @@ +```{dropdown} 3. Complete the anonymous pre-course survey + :class-container: sd-shadow-lg + :color: primary + +At the start of every course, I like to hear a little bit from my students and collect some information about them. +There is a good reason for this survey: I want to understand your current learning environments. Since we are all moving online forcibly, many of us may have challenges with available technology/equipment, or access to wireless internet (or power). +The more I understand your circumstances (anonymously), the more I hope to do to accommodate everyone in the class. + +Again, this is optional but please fill it out!! + +[Survey link](https://ubc.ca1.qualtrics.com/jfe/form/SV_7Oi7FwTWO2N5gMK?course=cpsc203&term=2023_WT2) +``` \ No newline at end of file diff --git a/getting-started/bits/07_take_a_break.md b/getting-started/bits/07_take_a_break.md new file mode 100644 index 0000000..e7ae652 --- /dev/null +++ b/getting-started/bits/07_take_a_break.md @@ -0,0 +1,13 @@ +```{dropdown} 3. [Required] Take a break! + :class-container: sd-shadow-lg + :color: success + :open: + +There's still a few days left before term starts, go outside, enjoy the freedom! +Rest, recover, heal from everything you've been through before the rigours of the new semester start. + +photo of a calm body of water near a forest in the lower mainland. + +Photo by [Jeremy Allouche on Unsplash](https://unsplash.com/photos/calm-body-of-water-near-forest-LLc-bFnJJ1o) + +``` \ No newline at end of file diff --git a/getting-started/bits/08_join_ed_discussion.md b/getting-started/bits/08_join_ed_discussion.md new file mode 100644 index 0000000..582cae6 --- /dev/null +++ b/getting-started/bits/08_join_ed_discussion.md @@ -0,0 +1,9 @@ +```{dropdown} 1. Join Ed Discussion and say hi! + :class-container: sd-shadow-lg + :color: primary + +You will be invited to Ed Discussion based on the email you enter [in this form](https://ubc.ca1.qualtrics.com)! +I will invite folks a couple of times a day. + + +``` \ No newline at end of file diff --git a/getting-started/bits/09_read_unsyllabus.md b/getting-started/bits/09_read_unsyllabus.md new file mode 100644 index 0000000..70eb4c1 --- /dev/null +++ b/getting-started/bits/09_read_unsyllabus.md @@ -0,0 +1,14 @@ +```{dropdown} 2. Read the Unsyllabus + :class-container: sd-shadow-lg + :color: primary + +The syllabus and unsyllabus is now live on Canvas under the "Course Content" sidebar item. You can also {{ '[view it outside of Canvas here]({link})'.format(link=COURSE_LINK) }}. + +I want to know what you think of the course unsyllabus! +Yes, I want your thoughts, feedback, and opinions on how you want the course to go this term. +If one of you has a good idea for a change, adjustment or addition - I'd love to adopt it if it fits with the course. +I strongly believe that you are now in charge of your own education, and I am just a guide to help point you in the right direction. + +The Unsyllabus also has lots of details about how this class will be run, my teaching philosophy, dates, due dates, and other course policies. +I encourage you to read it! +``` \ No newline at end of file diff --git a/getting-started/bits/0X.hypothesis.md b/getting-started/bits/0X.hypothesis.md new file mode 100644 index 0000000..7969b72 --- /dev/null +++ b/getting-started/bits/0X.hypothesis.md @@ -0,0 +1,26 @@ +```{dropdown} 🖊 X. Create a Hypothesis account (Optional) + :class-container: sd-shadow-lg + :color: success + :name: hypothesis + +There's a really awesome tool called [hypothes.is](https://hypothes.is) - when enabled, it allows anyone to highlight and comment on any website. +I have turned this feature on for our unsyllabus because I want to know what you think of the unsyllabus in our course! +Yes, it's *our* course, we're in this together and there are some opportunities for you to determine how we do things in this course. +I want your thoughts, feedback, and opinions on how you want the course to go this term. +Similarly, if you have any questions about any part of the unsyllabus, the best place to ask it is right in the document itself. +If you have a good idea for a change to the unsyllabus - I'd love to hear them, and even adopt them if they fit within the goals of the course. +I strongly believe that you are now in charge of your own education, and I am just a guide to help point you in the right direction! + +Here's an animated gif of how to annotate (you'll need to sign up for a free account): + + + +This is an experiment, and I encourage you to make comments and highlights on our unsyllabus. +Let's see how it goes! +Remember that your classmates will be able to see your comments too, so feel free to interact with them on here as well - we're in this together. +Don't be shy, but please also be respectful and courteous. +``` + +## Say Hello! + +If you created a Hypothes.is account, **select this bolded text** and make a comment about your favourite activity. \ No newline at end of file diff --git a/getting-started/bits/10_lab_location.md b/getting-started/bits/10_lab_location.md new file mode 100644 index 0000000..e944d61 --- /dev/null +++ b/getting-started/bits/10_lab_location.md @@ -0,0 +1,9 @@ +```{dropdown} 3. Figure out where your Labs will be held + :class-container: sd-shadow-lg + :color: primary + +On the [Student Service Center](https://courses.students.ubc.ca/cs/courseschedule?pname=subjarea&tname=subj-department&dept=CPSC), you can find the time, building, and room number of your lab. + +Once you know the building and room number, you can use the [UBC online interactive maps](https://maps.ubc.ca) to find the building. +It'll be worth it for you to spend some time figuring out where you need to be so you're not stressed out - labs will begin in Week 2! +``` \ No newline at end of file diff --git a/getting-started/bits/11_setup_computer.md b/getting-started/bits/11_setup_computer.md new file mode 100644 index 0000000..28df1ff --- /dev/null +++ b/getting-started/bits/11_setup_computer.md @@ -0,0 +1,8 @@ +```{dropdown} 3. Start setting up your computer + :class-container: sd-shadow-lg + :color: primary + +You should now start setting up your computer to install all the software necessary for the course, so that you are ready for all the class demos, labs, activities, etc... +The teaching team is available via {{ FORUM_LINK }} to support you through the process of installing the software on your personal machine. +You can click [Setup Your Machine](page_tech_stack). +``` \ No newline at end of file diff --git a/getting-started/bits/12_course_pattern.md b/getting-started/bits/12_course_pattern.md new file mode 100644 index 0000000..dd7fafa --- /dev/null +++ b/getting-started/bits/12_course_pattern.md @@ -0,0 +1,9 @@ +```{dropdown} 1. Get Familiar with the course pattern. + :class-container: sd-shadow-lg + :color: primary + :open: + +It is my intention to establish a "course pattern" where the only thing that changes from week-to-week is the specific content we're learning that week. +Otherwise, the pattern of videos, homework, class activities, tests, etc. will remain the same. +Set up a schedule for yourself so you can keep up with all the due dates for this course (and your other courses)! +``` \ No newline at end of file diff --git a/getting-started/bits/13_first_learninglog.md b/getting-started/bits/13_first_learninglog.md new file mode 100644 index 0000000..e2797a5 --- /dev/null +++ b/getting-started/bits/13_first_learninglog.md @@ -0,0 +1,9 @@ +```{dropdown} 2. Complete the first Learning Log (LL01) on PrairieLearn. + :class-container: sd-shadow-lg + :color: primary + :open: + +Once you're done everything else in the week and **after the last class of the week**, you should have access to the first Learning Log. +This assignment will help you get familiar with answering "Learning Log" questions and tasks on the PrairieLearn platform. +I will respond to your learning logs over the weekend, and next week, show you how to access your feedback. +``` \ No newline at end of file diff --git a/getting-started/bits/pre_term_faq.md b/getting-started/bits/pre_term_faq.md new file mode 100644 index 0000000..c94c26b --- /dev/null +++ b/getting-started/bits/pre_term_faq.md @@ -0,0 +1,158 @@ +## Frequently asked questions (before the term starts) + +````{dropdown} How do I address my professors at UBC? + :class-container: sd-shadow-lg + :color: primary + :name: how-to-address-professors + :open: + +```{tip} +In my opinion (and there are other opinions!) the short answer is: always use `Dr.` + `` or `Professor` + ``. +So you would call me `Dr. Moosvi` in emails and in-person. +``` + +The long answer is a bit of a rant, so bear with me here! + +```{dropdown} Read the long version here! + :class-container: sd-shadow-lg + :color: warning + +There is somewhat of a tension in the Ivory Tower as it has long been accepted and assumed that students at university are considered adults and thus, should be on a first-name basis with their professors. +After all, if we want students to be comfortable in their environment, and in the name of community-building then students should drop the formalities of titles and just refer to their professors using just their first name. +Well, it's a bit more complicated than that. +It turns out that in our society, job titles have a lot of meaning and authority - particularly for minoritized individuals such as women and people of colour, who are already less likely to be perceived as experts (see [this article](https://www.bbc.com/worklife/article/20210216-why-do-professional-titles-actually-matter) for more about this). +Of course it is very uncomfortable and socially inappropriate to "correct" people about your title, it seems like "bragging" or, being "uptight" and "hierarchical", as well as a host of other adjectives I'd rather not point out. +On the other hand, we also know that students come from a variety of different cultures and backgrounds and it may be completely inappropriate and foreign for them to refer to individuals of authority by their first names. +For these students, it can result in crippling anxiety and fear to refer to their instructors by their first names when they insist, so rather than deal with the turmoil of these interactions, they choose to not to interact with their instructors at all. +This is very unfortunate, and a reminder to us all that there are always consequences to our decisions and we need to think through our established conventions through the lens of "who is this harming?". + +Finally, I recognize that a lot of this may be "[hidden curriculum](https://www.edglossary.org/hidden-curriculum/)" and students may not be aware of these conventions. +I do not believe that students are intentionally referring to their instructors using incorrect honorifics (Mr., Ms., and the worst: Miss or Mrs). +However, it is an unfortunate and dark part of our society that it tends to happen way more to my female colleagues. +Practically speaking, in almost all cases^, and instructors here need a PhD to teach, so even if unintentional or accidental, you are devaluing their accomplishments and titles by referring to them as anything other than `Dr.` or `Professor`. +These titles that have been incredibly hard-earned (PhDs tend to have 5-7 years of additional education and training after a bachelor's degree), often in extremely traumatic circumstances (particularly for minoritized folks). +In general, I encourage you all to look within yourself and fight against your inner biases when it comes to equity and inclusion. +Specifically in this case, I suggest you **always** refer to your instructors at UBC with `Dr.` + `` or `Professor` + ``. + +^ *Note: In some cases, there may be exceptional senior grad students or exceptional teachers with Masters degrees, or substantial industrial experience teaching your courses. +Even in those cases - unless they tell you otherwise - it's usually wise (and polite) to refer to them as `Dr.` or `Professor` as well.* +``` + +```{tip} +👋🏽 If you have been referred to this page by me after an email exchange with me, please do not despair or feel bad! I do not think any less of you, I am just using this opportunity to educate you about appropriately addressing your instructors. There is absolutely no need to apologize, all is forgiven! Use this opportunity to learn more about this, and you'll do the right thing next time, I'm sure 😊! +``` +```` + +```{dropdown} What can I do if my study-permit is delayed and I can't be in Vancouver for the majority of the term? + :class-container: sd-shadow-lg + :color: primary + :name: missing-term + +You can find more advice about some next steps you can take [on this page that's managed by UBC](https://you.ubc.ca/applying-ubc/blog/after-youve-been-admitted/what-to-do-if-your-study-permit-hasnt-arrived-yet/). +``` + +```{dropdown} What are the computer requirements for this course? + :class-container: sd-shadow-lg + :color: primary + :name: computer-requirements +Before enrolling in this course, ensure that your laptop meets the minimum requirements: + +- runs one of the following operating systems: + - Macs: + - Latest: macOS 14.2.1 + - Recommended: macOS 10.14.6 or higher + - Required: macOS 10.11 (El Capitan) + - Windows: + - Latest: Windows 11 + - Recommended: Windows 10 (64-bit) or higher + - Required: Windows 7 or higher + - Ubuntu: + - Latest: Ubuntu 23.10 + - Recommended: Ubuntu 20.04 or higher + - Required: version 18.04 +- can connect to networks via a wireless connection +- has at least 25 GB disk space available +- has at least 4 GB of RAM +- uses English as the default language (if you want TAs or the instructor to help you) +- student user has full administrative access to the computer + +**We will do our best to help you if your laptop does not meet the minimum requirements, but there are no guarantees we will be able to get things to work so be warned.** + +If this is going to be a problem, please contact me through a private message on {{ FORUM_LINK }} and we can work out an accommodation. +``` + +```{dropdown} Do I need to buy anything for this course? + :class-container: sd-shadow-lg + :color: primary + :name: buy-anything + +No, you do not need to purchase anything for this course. + +It would be helpful if you had access to a computing device as we'll be conducting all of our homework, classwork, and labs digitally. If this is going to be a problem, please contact me through a private message on {{ FORUM_LINK }} and we can work out an accommodation. +``` + +```{dropdown} Which textbook are we using for this course? + :class-container: sd-shadow-lg + :color: primary + :name: textbook + +{{ TEXTBOOK }} +``` + +```{dropdown} Will lectures be recorded so I can re-watch them to study? + :class-container: sd-shadow-lg + :color: primary + :name: recorded-lectures + +Lectures may be recorded and will be posted if they are - mostly for students that miss the class and want to catch up on missed announcements. + +In general, I do not think re-watching lectures is a good way to study (even at 1.5x speed). +It will be far more beneficial for you to try doing more problems and come to student hours or get extra help on the forum! +``` + +````{dropdown} What should I do if the course is full and I'm on the waitlist for the class? + :class-container: sd-shadow-lg + :color: primary + :name: waitlist + +If the course is full, please see [this link here](https://www.cs.ubc.ca/students/undergrad/courses/waitlists) for guidance and frequently asked questions. + +If you are set on joining the class, I suggest attending class physically in-person for as long as possible so you are not behind if/when you do get into the course. +Note that attending classes will not increase or improve your chances to get admitted into the course. +Luckily, most of the content we use in this course is open source so you can {{ '[access the course website]({link})'.format(link=COURSE_LINK)}}. + +```{tip} +Unfortunately the **course instructor has no control over student registration** and you will not be able to join the Canvas course until you are officially registered in the class. +If you have specific questions, I suggest contacting an advisor. +``` +```` + +````{dropdown} What if I can't register in the lab/tutorial I want? + :class-container: sd-shadow-lg + :color: primary + :name: lab-tutorial + +You should refer to the [information provided here](https://www.cs.ubc.ca/students/undergrad/courses/labs). +```` + +```{dropdown} Is this course hard? Will I fail? + :class-container: sd-shadow-lg + :color: primary + :name: hard-course + +We have done our best to setup this course so that if you are willing (and able) to put the work in, you will leave this course with a good grades! +I can pretty much guarantee that - there are lots of opportunities for you to work collaboratively with your peers during the lectures and on homework assignments. +There will be frequent tests (roughly every two weeks) in this course and you will always have an opportunity to redo your test for a higher grade. + +If you come in with good work ethic, the right attitude, and sufficient motivation, you will do really well - I promise! +``` + +```{dropdown} Is attendance mandatory in lectures? + :class-container: sd-shadow-lg + :color: primary + :name: attendance + +- Attendance is **highly recommended** in lectures, but not required. +- Lectures may be recorded and if they are, will be made available via Canvas. +- Note that there are several passing requirements in this course - it's highly unlikely you'll be able to pass the course if you skip the lectures! +``` \ No newline at end of file diff --git a/getting-started/pre_term.md b/getting-started/pre_term.md new file mode 100644 index 0000000..1adf2d9 --- /dev/null +++ b/getting-started/pre_term.md @@ -0,0 +1,42 @@ +![](../images/header.jpg) + +![](../images/UBC_CS.png) + +(page_pre_term)= +# Before term starts + +Welcome to {{ COURSE_CODE }}, {{ TITLE }} ! +I am very excited that you've decided to enrol in my class. +Whether it's your choice to take this course, or if your were forced into it by your program/degree is not really that important - you're here now, and you're welcomed! +Many of you are entering your first year of university in a new city, and maybe even a new country! +To the students local to the area, you have a big responsibility to help your fellow students feel welcome and at home, in their new home. +Everyone should try and make the effort to make some new friends, study partners, and acquaintances. +We're emerging from a lockdowns and online learning, so don't think you're the only one whose social skills have severely deteriorated over the past few years! +Take the time to introduce yourselves, share your favourite places to go, hangout, eat, socialize etc. +Have fun with it, this is your new community! + +Silhouettes of a group of 6 friends running up the walls of what appears to be a giant pipe. Mountains and a blue sky in the background. + +Image by [Maike und Björn Bröskamp](https://pixabay.com/users/broesis-5213623/?utm_source=link-attribution&utm_medium=referral&utm_campaign=image&utm_content=2366955) from [Pixabay](https://pixabay.com//?utm_source=link-attribution&utm_medium=referral&utm_campaign=image&utm_content=2366955) + +I know that for some of you, the days before the term starts is filled with a nervous and anxious excitement, usually the good kind, but often the bad kind too. +I remember when I was a student, I would frantically check to see if course information was updated and whether there was a course website, what the class was going to be like, and if there was anything I could do to get ready for the start of class. +So when I became an instructor, I tried to reach out to my students a week or two before the term started to introduce myself and give them a few tasks to do to prepare for my class and the new school term. + +```{note} +Having some stuff to do before the term starts works for some students, but for others it really feels like I'm interrupting the last days of your summer vacations. Feel free to ignore this and come back to it whenever you're ready after the term has started! You won't be missing much and it really won't take that long to do. +``` + +Here is a list of things you can do (but don't have to) before the term starts: + +```{include} bits/01_student_email.md +``` + +```{include} bits/02_print.md +``` + +```{include} bits/07_take_a_break.md +``` + +```{include} bits/pre_term_faq.md +``` \ No newline at end of file diff --git a/getting-started/tasks1.md b/getting-started/tasks1.md new file mode 100755 index 0000000..cdbafc0 --- /dev/null +++ b/getting-started/tasks1.md @@ -0,0 +1,14 @@ +(page_pre_class)= +# Before the first class + +There are several things you'll need to do at the start of the course to get set up with all the technology, accounts, and services we'll be using. +I've split these tasks up into several chunks so it's a bit more manageable. + +```{include} bits/03_canvas_login.md +``` + +```{include} bits/04_github.md +``` + +```{include} bits/06_course_survey.md +``` \ No newline at end of file diff --git a/getting-started/tasks2.md b/getting-started/tasks2.md new file mode 100755 index 0000000..e4c76cb --- /dev/null +++ b/getting-started/tasks2.md @@ -0,0 +1,15 @@ +(page_post_class)= +# After the First Class + +There are several things you'll need to do at the start of the course to get set up with all the technology, accounts, and services we'll be using. +I've split these tasks up into several chunks so it's a bit more manageable. + +```{include} bits/08_join_ed_discussion.md +``` + +```{include} bits/09_read_unsyllabus.md +``` + +```{include} bits/11_setup_computer.md +``` + diff --git a/getting-started/tasks3.md b/getting-started/tasks3.md new file mode 100755 index 0000000..8bbd09b --- /dev/null +++ b/getting-started/tasks3.md @@ -0,0 +1,11 @@ +(page_first_week)= +# In the first week + +There are several things you'll need to do at the start of the course to get set up with all the technology, accounts, and services we'll be using. +I've split these tasks up into several chunks so it's a bit more manageable. + +```{include} bits/12_course_pattern.md +``` + +```{include} bits/13_first_learninglog.md +``` \ No newline at end of file diff --git a/images/Canvas_login.gif b/images/Canvas_login.gif new file mode 100644 index 0000000..8b76ee2 Binary files /dev/null and b/images/Canvas_login.gif differ diff --git a/images/EdDiscussion.gif b/images/EdDiscussion.gif new file mode 100644 index 0000000..180a8b0 Binary files /dev/null and b/images/EdDiscussion.gif differ diff --git a/images/GradescopeAccount.gif b/images/GradescopeAccount.gif new file mode 100644 index 0000000..87b91dd Binary files /dev/null and b/images/GradescopeAccount.gif differ diff --git a/images/UBC_CS.png b/images/UBC_CS.png new file mode 100644 index 0000000..3a92ec8 Binary files /dev/null and b/images/UBC_CS.png differ diff --git a/images/construction.jpeg b/images/construction.jpeg new file mode 100644 index 0000000..3bc5660 Binary files /dev/null and b/images/construction.jpeg differ diff --git a/images/friendship.jpg b/images/friendship.jpg new file mode 100644 index 0000000..d1e64b8 Binary files /dev/null and b/images/friendship.jpg differ diff --git a/images/header.jpg b/images/header.jpg new file mode 100644 index 0000000..b4923a4 Binary files /dev/null and b/images/header.jpg differ diff --git a/images/hypothesis_annotation.gif b/images/hypothesis_annotation.gif new file mode 100644 index 0000000..ef92a9c Binary files /dev/null and b/images/hypothesis_annotation.gif differ diff --git a/images/jeremy-allouche-LLc-bFnJJ1o-unsplash.jpg b/images/jeremy-allouche-LLc-bFnJJ1o-unsplash.jpg new file mode 100644 index 0000000..6502bbc Binary files /dev/null and b/images/jeremy-allouche-LLc-bFnJJ1o-unsplash.jpg differ diff --git a/images/logo.jpg b/images/logo.jpg new file mode 100644 index 0000000..31803c5 Binary files /dev/null and b/images/logo.jpg differ diff --git a/images/masterymodel1.pdf b/images/masterymodel1.pdf new file mode 100644 index 0000000..092ec23 Binary files /dev/null and b/images/masterymodel1.pdf differ diff --git a/images/masterymodel1.png b/images/masterymodel1.png new file mode 100644 index 0000000..e190684 Binary files /dev/null and b/images/masterymodel1.png differ diff --git a/images/masterymodel2.png b/images/masterymodel2.png new file mode 100644 index 0000000..af26c55 Binary files /dev/null and b/images/masterymodel2.png differ diff --git a/images/pl_sign_in.png b/images/pl_sign_in.png new file mode 100644 index 0000000..9b46243 Binary files /dev/null and b/images/pl_sign_in.png differ diff --git a/images/pledges.png b/images/pledges.png new file mode 100644 index 0000000..d639da8 Binary files /dev/null and b/images/pledges.png differ diff --git a/images/ubc_aerial.jpg b/images/ubc_aerial.jpg new file mode 100644 index 0000000..a09b6fa Binary files /dev/null and b/images/ubc_aerial.jpg differ diff --git a/images/work.png b/images/work.png new file mode 100644 index 0000000..08b9d33 Binary files /dev/null and b/images/work.png differ diff --git a/notes/demo01/demo01_summary.md b/notes/demo01/demo01_summary.md new file mode 100755 index 0000000..a726ec2 --- /dev/null +++ b/notes/demo01/demo01_summary.md @@ -0,0 +1,20 @@ +(page_topic1_demo)= +Week 1 +======================= + +This week we will be doing course introductions, I will be showing you how to navigate the course website, and how the course is set up. +In terms of content, we will use this week to do a math diagnostic, get everyone access to the textbook and homework system, and understand the syllabus. + +## Course Introductions! + +Hello, my name is Firas Moosvi and I am your instructor for Physics 111! + +## Navigating the course website + +Live demo... + +## Navigating Mastering Physics + +```{tip} +I have added an assignment called "Introduction to Mastering Physics" to help familiarize you with the interface. It is due, but there are no marks associated with it. +``` \ No newline at end of file diff --git a/notes/demo01/lecture1.ipynb b/notes/demo01/lecture1.ipynb new file mode 100644 index 0000000..e6619d2 --- /dev/null +++ b/notes/demo01/lecture1.ipynb @@ -0,0 +1,3478 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Introduction to Python" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In this class, we will watch the first of four lectures by Dr. Mike Gelbart, option co-director of the UBC-Vancouver MDS program." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "\n", + "
" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Attribution\n", + "\n", + "- The original version of these Python lectures were by [Patrick Walls](https://www.math.ubc.ca/~pwalls/).\n", + "- These lectures were delivered by [Mike Gelbart](https://mikegelbart.com) and are [available publicly here](https://www.youtube.com/watch?v=yBAYduexjuA)." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## About this course (5 min)\n", + "\n", + "### High-level overview:\n", + "\n", + "- The MDS program has a programming prerequisite.\n", + "- Therefore, this course does not start from \"no programming knowledge\".\n", + " - You should know what an `if` statement is.\n", + " - You should know what a `for` loop is.\n", + " - You should know what a function is.\n", + "- However, not all of you have used Python/R.\n", + "- So, this course is about _Python-specific_ and _R-specific_ syntax/knowledge.\n", + "- We will cover things like loops, but just the syntax, not the concept of a loop.\n", + "- Weeks 1&2: Python, lectures by Mike Gelbart\n", + "- Weeks 3&4: R, lectures by Tiffany Timbers" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Lecture Outline:\n", + "\n", + "- Basic datatypes (20 min)\n", + "- Lists and tuples (20 min)\n", + "- Break (5 min)\n", + "- String methods (5 min)\n", + "- Dictionaries (10 min)\n", + "- Conditionals (10 min)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Basic datatypes (20 min)\n", + "\n", + "- A **value** is a piece of data that a computer program works with such as a number or text. \n", + "- There are different **types** of values: `42` is an integer and `\"Hello!\"` is a string. \n", + "- A **variable** is a name that refers to a value. \n", + " - In mathematics and statistics, we usually use variables names like $x$ and $y$. \n", + " - In Python, we can use any word as a variable name (as long as it starts with a letter and is not a [reserved word](https://docs.python.org/3.3/reference/lexical_analysis.html#keywords) in Python such as `for`, `while`, `class`, `lambda`, etc.). \n", + "- And we use the **assignment operator** `=` to assign a value to a variable.\n", + "\n", + "See the [Python 3 documentation](https://docs.python.org/3/library/stdtypes.html) for a summary of the standard built-in Python datatypes. See [Think Python (Chapter 2)](http://greenteapress.com/thinkpython/html/thinkpython003.html) for a discussion of variables, expressions and statements in Python." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Common built-in Python data types\n", + "\n", + "| English name | Type name | Description | Example |\n", + "| :--- | :--- | :--- | :--- |\n", + "| integer | `int` | positive/negative whole numbers | `42` |\n", + "| floating point number | `float` | real number in decimal form | `3.14159` |\n", + "| boolean | `bool` | true or false | `True` |\n", + "| string | `str` | text | `\"I Can Has Cheezburger?\"` |\n", + "| list | `list` | a collection of objects - mutable & ordered | `['Ali','Xinyi','Miriam']` |\n", + "| tuple | `tuple` | a collection of objects - immutable & ordered | `('Thursday',6,9,2018)` |\n", + "| dictionary | `dict` | mapping of key-value pairs | `{'name':'DSCI','code':511,'credits':2}` |\n", + "| none | `NoneType` | represents no value | `None` |" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Numeric Types" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "x = 42" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "int" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(x)" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "42\n" + ] + } + ], + "source": [ + "print(x)" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "42" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "x # in Jupyter/IPython we don't need to explicitly print for the last line of a cell" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "pi = 3.14159" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3.14159\n" + ] + } + ], + "source": [ + "print(pi)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "float" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(pi)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [], + "source": [ + "λ = 2" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Arithmetic Operators\n", + "\n", + "The syntax for the arithmetic operators are:\n", + "\n", + "| Operator | Description |\n", + "| :---: | :---: |\n", + "| `+` | addition |\n", + "| `-` | subtraction |\n", + "| `*` | multiplication |\n", + "| `/` | division |\n", + "| `**` | exponentiation |\n", + "| `//` | integer division |\n", + "| `%` | modulo |\n", + "\n", + "Let's apply these operators to numeric types and observe the results." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "15" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "1 + 2 + 3 + 4 + 5" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0.30000000000000004" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "0.1 + 0.2" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "```{tip}\n", + "From Firas: This is floating point arithmetic. For an explanation of what's going on, [see this tutorial](https://docs.python.org/3/tutorial/floatingpoint.html).\n", + "```" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "6.28318" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "2 * 3.14159" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1024" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "2**10" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "int" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(2**10)" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1024.0" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "2.0**10" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [], + "source": [ + "int_2 = 2" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [], + "source": [ + "float_2 = 2.0" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [], + "source": [ + "float_2_again = 2." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "50.5" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "101 / 2" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "50" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "101 // 2 # \"integer division\" - always rounds down" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "101 % 2 # \"101 mod 2\", or the remainder when 101 is divided by 2" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### None\n", + "\n", + "- `NoneType` is its own type in Python.\n", + "- It only has one possible value, `None`" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": {}, + "outputs": [], + "source": [ + "x = None" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "None\n" + ] + } + ], + "source": [ + "print(x)" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "NoneType" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(x)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "You may have seen similar things in other languages, like `null` in Java, etc." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Strings\n", + "\n", + "- Text is stored as a type called a string. \n", + "- We think of a string as a sequence of characters. \n", + "- We write strings as characters enclosed with either:\n", + " - single quotes, e.g., `'Hello'` \n", + " - double quotes, e.g., `\"Goodbye\"`\n", + " - triple single quotes, e.g., `'''Yesterday'''`\n", + " - triple double quotes, e.g., `\"\"\"Tomorrow\"\"\"`" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": {}, + "outputs": [], + "source": [ + "my_name = \"Mike Gelbart\"" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Mike Gelbart\n" + ] + } + ], + "source": [ + "print(my_name)" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "str" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(my_name)" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [], + "source": [ + "course = 'DSCI 511'" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "DSCI 511\n" + ] + } + ], + "source": [ + "print(course)" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "str" + ] + }, + "execution_count": 33, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(course)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "If the string contains a quotation or apostrophe, we can use double quotes or triple quotes to define the string." + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": {}, + "outputs": [], + "source": [ + "sentence = \"It's a rainy day.\"" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "It's a rainy day.\n" + ] + } + ], + "source": [ + "print(sentence)" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "str" + ] + }, + "execution_count": 36, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(sentence)" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": {}, + "outputs": [], + "source": [ + "saying = '''They say: \n", + "\"It's a rainy day!\"'''" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "They say: \n", + "\"It's a rainy day!\"\n" + ] + } + ], + "source": [ + "print(saying)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Boolean\n", + "\n", + "- The Boolean (`bool`) type has two values: `True` and `False`. " + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": {}, + "outputs": [], + "source": [ + "the_truth = True" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n" + ] + } + ], + "source": [ + "print(the_truth)" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "bool" + ] + }, + "execution_count": 42, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(the_truth)" + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "metadata": {}, + "outputs": [], + "source": [ + "lies = False" + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "False\n" + ] + } + ], + "source": [ + "print(lies)" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "bool" + ] + }, + "execution_count": 45, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(lies)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Comparison Operators\n", + "\n", + "Compare objects using comparison operators. The result is a Boolean value.\n", + "\n", + "| Operator | Description |\n", + "| :---: | :--- |\n", + "| `x == y ` | is `x` equal to `y`? |\n", + "| `x != y` | is `x` not equal to `y`? |\n", + "| `x > y` | is `x` greater than `y`? |\n", + "| `x >= y` | is `x` greater than or equal to `y`? |\n", + "| `x < y` | is `x` less than `y`? |\n", + "| `x <= y` | is `x` less than or equal to `y`? |\n", + "| `x is y` | is `x` the same object as `y`? |" + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 46, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "2 < 3" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 47, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "\"Data Science\" != \"Deep Learning\"" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 48, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "2 == \"2\"" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 49, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "2 == 2.0" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Note: we will discuss `is` next week." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Operators on Boolean values.\n", + "\n", + "| Operator | Description |\n", + "| :---: | :--- |\n", + "|`x and y`| are `x` and `y` both true? |\n", + "|`x or y` | is at least one of `x` and `y` true? |\n", + "| `not x` | is `x` false? | " + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 51, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "True and True" + ] + }, + { + "cell_type": "code", + "execution_count": 50, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 50, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "True and False" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 52, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "False or False" + ] + }, + { + "cell_type": "code", + "execution_count": 53, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 53, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(\"Python 2\" != \"Python 3\") and (2 <= 3)" + ] + }, + { + "cell_type": "code", + "execution_count": 54, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 54, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "not True" + ] + }, + { + "cell_type": "code", + "execution_count": 55, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 55, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "not not True" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Casting\n", + "\n", + "- Sometimes (but rarely) we need to explicitly **cast** a value from one type to another.\n", + "- Python tries to do something reasonable, or throws an error if it has no ideas." + ] + }, + { + "cell_type": "code", + "execution_count": 56, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "5" + ] + }, + "execution_count": 56, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "x = int(5.0)\n", + "x" + ] + }, + { + "cell_type": "code", + "execution_count": 57, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "int" + ] + }, + "execution_count": 57, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(x)" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'5.0'" + ] + }, + "execution_count": 58, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "x = str(5.0)\n", + "x" + ] + }, + { + "cell_type": "code", + "execution_count": 59, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "str" + ] + }, + "execution_count": 59, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(x)" + ] + }, + { + "cell_type": "code", + "execution_count": 60, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 60, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "str(5.0) == 5.0" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "execution": { + "iopub.execute_input": "2021-01-10T01:58:33.810Z", + "iopub.status.busy": "2021-01-10T01:58:33.749Z", + "iopub.status.idle": "2021-01-10T01:58:33.909Z", + "shell.execute_reply": "2021-01-10T01:58:33.594Z" + } + }, + "outputs": [], + "source": [ + "# list(5.0) # there is no reasonable thing to do here" + ] + }, + { + "cell_type": "code", + "execution_count": 62, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "5" + ] + }, + "execution_count": 62, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "int(5.3)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Lists and Tuples (20 min)\n", + "\n", + "- Lists and tuples allow us to store multiple things (\"elements\") in a single object.\n", + "- The elements are _ordered_." + ] + }, + { + "cell_type": "code", + "execution_count": 63, + "metadata": {}, + "outputs": [], + "source": [ + "my_list = [1, 2, \"THREE\", 4, 0.5]" + ] + }, + { + "cell_type": "code", + "execution_count": 65, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[1, 2, 'THREE', 4, 0.5]\n" + ] + } + ], + "source": [ + "print(my_list)" + ] + }, + { + "cell_type": "code", + "execution_count": 66, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "list" + ] + }, + "execution_count": 66, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(my_list)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "You can get the length of the list with `len`:" + ] + }, + { + "cell_type": "code", + "execution_count": 67, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "5" + ] + }, + "execution_count": 67, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len(my_list)" + ] + }, + { + "cell_type": "code", + "execution_count": 68, + "metadata": {}, + "outputs": [], + "source": [ + "today = (1, 2, \"THREE\", 4, 0.5)" + ] + }, + { + "cell_type": "code", + "execution_count": 69, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(1, 2, 'THREE', 4, 0.5)\n" + ] + } + ], + "source": [ + "print(today)" + ] + }, + { + "cell_type": "code", + "execution_count": 70, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "tuple" + ] + }, + "execution_count": 70, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(today)" + ] + }, + { + "cell_type": "code", + "execution_count": 71, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "5" + ] + }, + "execution_count": 71, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len(today)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Indexing and Slicing Sequences\n", + "\n", + "- We can access values inside a list, tuple, or string using the backet syntax. \n", + "- Python uses zero-based indexing, which means the first element of the list is in position 0, not position 1. \n", + "- Sadly, R uses one-based indexing, so get ready to be confused." + ] + }, + { + "cell_type": "code", + "execution_count": 72, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[1, 2, 'THREE', 4, 0.5]" + ] + }, + "execution_count": 72, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "my_list" + ] + }, + { + "cell_type": "code", + "execution_count": 73, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1" + ] + }, + "execution_count": 73, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "my_list[0]" + ] + }, + { + "cell_type": "code", + "execution_count": 74, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0.5" + ] + }, + "execution_count": 74, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "my_list[4]" + ] + }, + { + "cell_type": "code", + "execution_count": 75, + "metadata": { + "tags": [ + "skip-execution" + ] + }, + "outputs": [ + { + "ename": "IndexError", + "evalue": "list index out of range", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mmy_list\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m5\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;31mIndexError\u001b[0m: list index out of range" + ] + } + ], + "source": [ + "my_list[5]" + ] + }, + { + "cell_type": "code", + "execution_count": 77, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0.5" + ] + }, + "execution_count": 77, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "today[4]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We use negative indices to count backwards from the end of the list." + ] + }, + { + "cell_type": "code", + "execution_count": 80, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[1, 2, 'THREE', 4, 0.5]" + ] + }, + "execution_count": 80, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "my_list" + ] + }, + { + "cell_type": "code", + "execution_count": 81, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0.5" + ] + }, + "execution_count": 81, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "my_list[-1]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We use the colon `:` to access a subsequence. This is called \"slicing\"." + ] + }, + { + "cell_type": "code", + "execution_count": 84, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[2, 'THREE', 4]" + ] + }, + "execution_count": 84, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "my_list[1:4]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Above: note that the start is inclusive and the end is exclusive.\n", + "- So `my_list[1:3]` fetches elements 1 and 2, but not 3.\n", + "- In other words, it gets the 2nd and 3rd elements in the list." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can omit the start or end:" + ] + }, + { + "cell_type": "code", + "execution_count": 85, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[1, 2, 'THREE']" + ] + }, + "execution_count": 85, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "my_list[:3]" + ] + }, + { + "cell_type": "code", + "execution_count": 86, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[4, 0.5]" + ] + }, + "execution_count": 86, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "my_list[3:]" + ] + }, + { + "cell_type": "code", + "execution_count": 87, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[1, 2, 'THREE', 4, 0.5]" + ] + }, + "execution_count": 87, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "my_list[:] # *almost* same as my_list - more details next week" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Strings behave the same as lists and tuples when it comes to indexing and slicing." + ] + }, + { + "cell_type": "code", + "execution_count": 88, + "metadata": {}, + "outputs": [], + "source": [ + "alphabet = \"abcdefghijklmnopqrstuvwxyz\"" + ] + }, + { + "cell_type": "code", + "execution_count": 89, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'a'" + ] + }, + "execution_count": 89, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "alphabet[0]" + ] + }, + { + "cell_type": "code", + "execution_count": 90, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'z'" + ] + }, + "execution_count": 90, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "alphabet[-1]" + ] + }, + { + "cell_type": "code", + "execution_count": 91, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'x'" + ] + }, + "execution_count": 91, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "alphabet[-3]" + ] + }, + { + "cell_type": "code", + "execution_count": 92, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'abcde'" + ] + }, + "execution_count": 92, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "alphabet[:5]" + ] + }, + { + "cell_type": "code", + "execution_count": 93, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'mnopqrst'" + ] + }, + "execution_count": 93, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "alphabet[12:20]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### List Methods\n", + "\n", + "- A list is an object and it has methods for interacting with its data. \n", + "- For example, `list.append(item)` appends an item to the end of the list. \n", + "- See the documentation for more [list methods](https://docs.python.org/3/tutorial/datastructures.html#more-on-lists)." + ] + }, + { + "cell_type": "code", + "execution_count": 94, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[2, 3, 5, 7, 11]" + ] + }, + "execution_count": 94, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "primes = [2,3,5,7,11]\n", + "primes" + ] + }, + { + "cell_type": "code", + "execution_count": 95, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "5" + ] + }, + "execution_count": 95, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len(primes)" + ] + }, + { + "cell_type": "code", + "execution_count": 114, + "metadata": {}, + "outputs": [], + "source": [ + "primes.append(13)" + ] + }, + { + "cell_type": "code", + "execution_count": 115, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[2,\n", + " 3,\n", + " 5,\n", + " 7,\n", + " 11,\n", + " 13,\n", + " 13,\n", + " 13,\n", + " 13,\n", + " 13,\n", + " 13,\n", + " 13,\n", + " 13,\n", + " 13,\n", + " 13,\n", + " 13,\n", + " 13,\n", + " 13,\n", + " 13,\n", + " 13,\n", + " 13,\n", + " 13]" + ] + }, + "execution_count": 115, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "primes" + ] + }, + { + "cell_type": "code", + "execution_count": 116, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "22" + ] + }, + "execution_count": 116, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len(primes)" + ] + }, + { + "cell_type": "code", + "execution_count": 117, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "13" + ] + }, + "execution_count": 117, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "max(primes)" + ] + }, + { + "cell_type": "code", + "execution_count": 118, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "2" + ] + }, + "execution_count": 118, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "min(primes)" + ] + }, + { + "cell_type": "code", + "execution_count": 119, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "249" + ] + }, + "execution_count": 119, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sum(primes)" + ] + }, + { + "cell_type": "code", + "execution_count": 120, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[1, 2, 3, 'Hello', 7]" + ] + }, + "execution_count": 120, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "[1,2,3] + [\"Hello\", 7]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Sets\n", + "\n", + "- Another built-in Python data type is the `set`, which stores an _un-ordered_ list of _unique_ items.\n", + "- More on sets in DSCI 512." + ] + }, + { + "cell_type": "code", + "execution_count": 121, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{2, 3, 5, 11}" + ] + }, + "execution_count": 121, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "s = {2,3,5,11}\n", + "s" + ] + }, + { + "cell_type": "code", + "execution_count": 122, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 122, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "{1,2,3} == {3,2,1}" + ] + }, + { + "cell_type": "code", + "execution_count": 123, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 123, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "[1,2,3] == [3,2,1]" + ] + }, + { + "cell_type": "code", + "execution_count": 124, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{2, 3, 5, 11}" + ] + }, + "execution_count": 124, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "s.add(2) # does nothing\n", + "s" + ] + }, + { + "cell_type": "code", + "execution_count": 125, + "metadata": { + "tags": [ + "skip-execution" + ] + }, + "outputs": [ + { + "ename": "TypeError", + "evalue": "'set' object is not subscriptable", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0ms\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m: 'set' object is not subscriptable" + ] + } + ], + "source": [ + "s[0]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Above: throws an error because elements are not ordered." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Mutable vs. Immutable Types\n", + "\n", + "- Strings and tuples are immutable types which means they cannot be modified. \n", + "- Lists are mutable and we can assign new values for its various entries. \n", + "- This is the main difference between lists and tuples." + ] + }, + { + "cell_type": "code", + "execution_count": 126, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['Indiana', 'Fang', 'Linsey']" + ] + }, + "execution_count": 126, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "names_list = [\"Indiana\",\"Fang\",\"Linsey\"]\n", + "names_list" + ] + }, + { + "cell_type": "code", + "execution_count": 128, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['Cool guy', 'Fang', 'Linsey']" + ] + }, + "execution_count": 128, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "names_list[0] = \"Cool guy\"\n", + "names_list" + ] + }, + { + "cell_type": "code", + "execution_count": 129, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "('Indiana', 'Fang', 'Linsey')" + ] + }, + "execution_count": 129, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "names_tuple = (\"Indiana\",\"Fang\",\"Linsey\")\n", + "names_tuple" + ] + }, + { + "cell_type": "code", + "execution_count": 130, + "metadata": { + "tags": [ + "skip-execution" + ] + }, + "outputs": [ + { + "ename": "TypeError", + "evalue": "'tuple' object does not support item assignment", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mnames_tuple\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m\"Not cool guy\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m: 'tuple' object does not support item assignment" + ] + } + ], + "source": [ + "names_tuple[0] = \"Not cool guy\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Same goes for strings. Once defined we cannot modifiy the characters of the string." + ] + }, + { + "cell_type": "code", + "execution_count": 131, + "metadata": {}, + "outputs": [], + "source": [ + "my_name = \"Mike\"" + ] + }, + { + "cell_type": "code", + "execution_count": 132, + "metadata": { + "tags": [ + "skip-execution" + ] + }, + "outputs": [ + { + "ename": "TypeError", + "evalue": "'str' object does not support item assignment", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mmy_name\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m'q'\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m: 'str' object does not support item assignment" + ] + } + ], + "source": [ + "my_name[-1] = 'q'" + ] + }, + { + "cell_type": "code", + "execution_count": 137, + "metadata": {}, + "outputs": [], + "source": [ + "x = ([1,2,3],5)" + ] + }, + { + "cell_type": "code", + "execution_count": 138, + "metadata": { + "tags": [ + "skip-execution" + ] + }, + "outputs": [ + { + "ename": "TypeError", + "evalue": "'tuple' object does not support item assignment", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mx\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m7\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m: 'tuple' object does not support item assignment" + ] + } + ], + "source": [ + "x[1] = 7" + ] + }, + { + "cell_type": "code", + "execution_count": 139, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "([1, 2, 3], 5)" + ] + }, + "execution_count": 139, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "x" + ] + }, + { + "cell_type": "code", + "execution_count": 140, + "metadata": {}, + "outputs": [], + "source": [ + "x[0][1] = 4" + ] + }, + { + "cell_type": "code", + "execution_count": 141, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "([1, 4, 3], 5)" + ] + }, + "execution_count": 141, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "x" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Break (5 min)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## String Methods (5 min)\n", + "\n", + "- There are various useful string methods in Python.\n", + "- MDS-CL students will soon be the experts we can go to for help!" + ] + }, + { + "cell_type": "code", + "execution_count": 142, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "HOW ARE YOU TODAY?\n" + ] + } + ], + "source": [ + "all_caps = \"HOW ARE YOU TODAY?\"\n", + "print(all_caps)" + ] + }, + { + "cell_type": "code", + "execution_count": 145, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'how are you today?'" + ] + }, + "execution_count": 145, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "new_str = all_caps.lower()\n", + "new_str" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Note that the method lower doesn't change the original string but rather returns a new one.\n" + ] + }, + { + "cell_type": "code", + "execution_count": 146, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'HOW ARE YOU TODAY?'" + ] + }, + "execution_count": 146, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "all_caps" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "There are *many* string methods. Check out the [documentation](https://docs.python.org/3/library/stdtypes.html#string-methods)." + ] + }, + { + "cell_type": "code", + "execution_count": 147, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['HOW', 'ARE', 'YOU', 'TODAY?']" + ] + }, + "execution_count": 147, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "all_caps.split()" + ] + }, + { + "cell_type": "code", + "execution_count": 148, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "3" + ] + }, + "execution_count": 148, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "all_caps.count(\"O\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "One can explicitly cast a string to a list:" + ] + }, + { + "cell_type": "code", + "execution_count": 151, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['H',\n", + " 'O',\n", + " 'W',\n", + " ' ',\n", + " 'A',\n", + " 'R',\n", + " 'E',\n", + " ' ',\n", + " 'Y',\n", + " 'O',\n", + " 'U',\n", + " ' ',\n", + " 'T',\n", + " 'O',\n", + " 'D',\n", + " 'A',\n", + " 'Y',\n", + " '?']" + ] + }, + "execution_count": 151, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "caps_list = list(all_caps)\n", + "caps_list" + ] + }, + { + "cell_type": "code", + "execution_count": 152, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "18" + ] + }, + "execution_count": 152, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len(all_caps)" + ] + }, + { + "cell_type": "code", + "execution_count": 153, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "18" + ] + }, + "execution_count": 153, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len(caps_list)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### String formatting\n", + "\n", + "- Python has ways of creating strings by \"filling in the blanks\" and formatting them nicely. \n", + "- There are a few ways of doing this. See [here](https://realpython.com/python-string-formatting/) and [here](https://stackoverflow.com/questions/5082452/string-formatting-vs-format) for some discussion." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Old formatting style (borrowed from the C programming language):" + ] + }, + { + "cell_type": "code", + "execution_count": 154, + "metadata": {}, + "outputs": [], + "source": [ + "template = \"Hello, my name is %s. I am %.2f years old.\"" + ] + }, + { + "cell_type": "code", + "execution_count": 155, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'Hello, my name is Newborn Baby. I am 0.33 years old.'" + ] + }, + "execution_count": 155, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "template % (\"Newborn Baby\", 4/12)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "New formatting style (see [documentation](https://docs.python.org/3/library/stdtypes.html#str.format)):" + ] + }, + { + "cell_type": "code", + "execution_count": 156, + "metadata": {}, + "outputs": [], + "source": [ + "template_new = \"Hello, my name is {}. I am {:.2f} years old.\"" + ] + }, + { + "cell_type": "code", + "execution_count": 157, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'Hello, my name is Newborn Baby. I am 0.33 years old.'" + ] + }, + "execution_count": 157, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "template_new.format('Newborn Baby', 4/12)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Newer formatting style (see [here](https://realpython.com/python-f-strings/#f-strings-a-new-and-improved-way-to-format-strings-in-python)) - note the `f` before the start of the string:" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'Hello, my name is Newborn Baby. I am 0.33 years old.'" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "name = \"Newborn Baby\"\n", + "age = 4/12\n", + "template_new = f'Hello, my name is {name}. I am {age:.2f} years old.'\n", + "template_new" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Dictionaries (10 min)\n", + "\n", + "A dictionary is a mapping between key-values pairs." + ] + }, + { + "cell_type": "code", + "execution_count": 158, + "metadata": {}, + "outputs": [], + "source": [ + "house = {'bedrooms': 3, 'bathrooms': 2, 'city': 'Vancouver', 'price': 2499999, 'date_sold': (1,3,2015)}\n", + "\n", + "condo = {'bedrooms' : 2, \n", + " 'bathrooms': 1, \n", + " 'city' : 'Burnaby', \n", + " 'price' : 699999, \n", + " 'date_sold': (27,8,2011)\n", + " }" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can access a specific field of a dictionary with square brackets:" + ] + }, + { + "cell_type": "code", + "execution_count": 159, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "2499999" + ] + }, + "execution_count": 159, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "house['price']" + ] + }, + { + "cell_type": "code", + "execution_count": 160, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'Burnaby'" + ] + }, + "execution_count": 160, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "condo['city']" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can also edit dictionaries (they are mutable):" + ] + }, + { + "cell_type": "code", + "execution_count": 162, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'bedrooms': 2,\n", + " 'bathrooms': 1,\n", + " 'city': 'Burnaby',\n", + " 'price': 5,\n", + " 'date_sold': (27, 8, 2011)}" + ] + }, + "execution_count": 162, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "condo['price'] = 5 # price already in the dict\n", + "condo" + ] + }, + { + "cell_type": "code", + "execution_count": 163, + "metadata": {}, + "outputs": [], + "source": [ + "condo['flooring'] = \"wood\"" + ] + }, + { + "cell_type": "code", + "execution_count": 164, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'bedrooms': 2,\n", + " 'bathrooms': 1,\n", + " 'city': 'Burnaby',\n", + " 'price': 5,\n", + " 'date_sold': (27, 8, 2011),\n", + " 'flooring': 'wood'}" + ] + }, + "execution_count": 164, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "condo" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can delete fields entirely (though I rarely use this):" + ] + }, + { + "cell_type": "code", + "execution_count": 165, + "metadata": {}, + "outputs": [], + "source": [ + "del condo[\"city\"]" + ] + }, + { + "cell_type": "code", + "execution_count": 166, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'bedrooms': 2,\n", + " 'bathrooms': 1,\n", + " 'price': 5,\n", + " 'date_sold': (27, 8, 2011),\n", + " 'flooring': 'wood'}" + ] + }, + "execution_count": 166, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "condo" + ] + }, + { + "cell_type": "code", + "execution_count": 167, + "metadata": {}, + "outputs": [], + "source": [ + "condo[5] = 443345" + ] + }, + { + "cell_type": "code", + "execution_count": 168, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'bedrooms': 2,\n", + " 'bathrooms': 1,\n", + " 'price': 5,\n", + " 'date_sold': (27, 8, 2011),\n", + " 'flooring': 'wood',\n", + " 5: 443345}" + ] + }, + "execution_count": 168, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "condo" + ] + }, + { + "cell_type": "code", + "execution_count": 169, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'bedrooms': 2,\n", + " 'bathrooms': 1,\n", + " 'price': 5,\n", + " 'date_sold': (27, 8, 2011),\n", + " 'flooring': 'wood',\n", + " 5: 443345,\n", + " (1, 2, 3): 777}" + ] + }, + "execution_count": 169, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "condo[(1,2,3)] = 777\n", + "condo" + ] + }, + { + "cell_type": "code", + "execution_count": 170, + "metadata": {}, + "outputs": [ + { + "ename": "KeyError", + "evalue": "'nothere'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mcondo\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"nothere\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;31mKeyError\u001b[0m: 'nothere'" + ] + } + ], + "source": [ + "condo[\"nothere\"]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "A sometimes useful trick about default values:" + ] + }, + { + "cell_type": "code", + "execution_count": 171, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "2" + ] + }, + "execution_count": 171, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "condo[\"bedrooms\"]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "is shorthand for" + ] + }, + { + "cell_type": "code", + "execution_count": 172, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "2" + ] + }, + "execution_count": 172, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "condo.get(\"bedrooms\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "With this syntax you can also use default values:" + ] + }, + { + "cell_type": "code", + "execution_count": 173, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "2" + ] + }, + "execution_count": 173, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "condo.get(\"bedrooms\", \"unknown\")" + ] + }, + { + "cell_type": "code", + "execution_count": 174, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'unknown'" + ] + }, + "execution_count": 174, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "condo.get(\"fireplaces\", \"unknown\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- A common operation is finding the maximum dictionary key by value.\n", + "- There are a few ways to do this, see [this StackOverflow page](https://stackoverflow.com/questions/268272/getting-key-with-maximum-value-in-dictionary).\n", + "- One way of doing it:" + ] + }, + { + "cell_type": "code", + "execution_count": 175, + "metadata": {}, + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'word_lengths' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mmax\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mword_lengths\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkey\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mword_lengths\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;31mNameError\u001b[0m: name 'word_lengths' is not defined" + ] + } + ], + "source": [ + "max(word_lengths, key=word_lengths.get)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We saw `word_lengths.get` above - it is saying that we should call this function on each key of the dict to decide how to sort." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Empties" + ] + }, + { + "cell_type": "code", + "execution_count": 176, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[]" + ] + }, + "execution_count": 176, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "lst = list() # empty list\n", + "lst" + ] + }, + { + "cell_type": "code", + "execution_count": 177, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[]" + ] + }, + "execution_count": 177, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "lst = [] # empty list\n", + "lst" + ] + }, + { + "cell_type": "code", + "execution_count": 178, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "()" + ] + }, + "execution_count": 178, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "tup = tuple() # empty tuple\n", + "tup" + ] + }, + { + "cell_type": "code", + "execution_count": 179, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "()" + ] + }, + "execution_count": 179, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "tup = () # empty tuple\n", + "tup" + ] + }, + { + "cell_type": "code", + "execution_count": 180, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{}" + ] + }, + "execution_count": 180, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dic = dict() # empty dict\n", + "dic" + ] + }, + { + "cell_type": "code", + "execution_count": 181, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{}" + ] + }, + "execution_count": 181, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dic = {} # empty dict\n", + "dic" + ] + }, + { + "cell_type": "code", + "execution_count": 182, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "set()" + ] + }, + "execution_count": 182, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "st = set() # emtpy set\n", + "st" + ] + }, + { + "cell_type": "code", + "execution_count": 183, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "dict" + ] + }, + "execution_count": 183, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "st = {} # NOT an empty set!\n", + "type(st)" + ] + }, + { + "cell_type": "code", + "execution_count": 184, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "set" + ] + }, + "execution_count": 184, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "st = {1}\n", + "type(st)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Conditionals (10 min)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- [Conditional statements](https://docs.python.org/3/tutorial/controlflow.html) allow us to write programs where only certain blocks of code are executed depending on the state of the program. \n", + "- Let's look at some examples and take note of the keywords, syntax and indentation. \n", + "- Check out the [Python documentation](https://docs.python.org/3/tutorial/controlflow.html) and [Think Python (Chapter 5)](http://greenteapress.com/thinkpython/html/thinkpython006.html) for more information about conditional execution." + ] + }, + { + "cell_type": "code", + "execution_count": 189, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "What's your name?mike\n", + "That's my name too!\n" + ] + } + ], + "source": [ + "name = input(\"What's your name?\")\n", + "\n", + "if name.lower() == 'mike':\n", + " print(\"That's my name too!\")\n", + "elif name.lower() == 'santa':\n", + " print(\"That's a funny name.\")\n", + "else:\n", + " print(\"Hello {}! That's a cool name.\".format(name))\n", + "\n", + " print('Nice to meet you!')" + ] + }, + { + "cell_type": "code", + "execution_count": 190, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 190, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "bool(None)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The main points to notice:\n", + "\n", + "* Use keywords `if`, `elif` and `else`\n", + "* The colon `:` ends each conditional expression\n", + "* Indentation (by 4 empty space) defines code blocks\n", + "* In an `if` statement, the first block whose conditional statement returns `True` is executed and the program exits the `if` block\n", + "* `if` statements don't necessarily need `elif` or `else`\n", + "* `elif` lets us check several conditions\n", + "* `else` lets us evaluate a default block if all other conditions are `False`\n", + "* the end of the entire `if` statement is where the indentation returns to the same level as the first `if` keyword" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "If statements can also be **nested** inside of one another:" + ] + }, + { + "cell_type": "code", + "execution_count": 192, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "What's your name?supersam\n", + "Hello supersam! That's a cool name.\n", + "Do you have superpowers?\n", + "Nice to meet you!\n" + ] + } + ], + "source": [ + "name = input(\"What's your name?\")\n", + "\n", + "if name.lower() == 'mike':\n", + " print(\"That's my name too!\")\n", + "elif name.lower() == 'santa':\n", + " print(\"That's a funny name.\")\n", + "else:\n", + " print(\"Hello {0}! That's a cool name.\".format(name))\n", + " if name.lower().startswith(\"super\"):\n", + " print(\"Do you have superpowers?\")\n", + "\n", + "print('Nice to meet you!')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Inline if/else" + ] + }, + { + "cell_type": "code", + "execution_count": 193, + "metadata": { + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'short list'" + ] + }, + "execution_count": 193, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "words = [\"the\", \"list\", \"of\", \"words\"]\n", + "\n", + "x = \"long list\" if len(words) > 10 else \"short list\"\n", + "x" + ] + }, + { + "cell_type": "code", + "execution_count": 194, + "metadata": {}, + "outputs": [], + "source": [ + "if len(words) > 10:\n", + " x = \"long list\"\n", + "else:\n", + " x = \"short list\"" + ] + }, + { + "cell_type": "code", + "execution_count": 195, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'short list'" + ] + }, + "execution_count": 195, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "x" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### (optional) short-circruiting" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "BLAH # not defined" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "True or BLAH" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "True and BLAH" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "False and BLAH" + ] + } + ], + "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.8.3" + }, + "nteract": { + "version": "0.27.0" + }, + "toc-showmarkdowntxt": false, + "toc-showtags": false + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/notes/demo01/lecture2.ipynb b/notes/demo01/lecture2.ipynb new file mode 100644 index 0000000..2f0b6ac --- /dev/null +++ b/notes/demo01/lecture2.ipynb @@ -0,0 +1,814 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "source": [ + "# Platforms for Data Science" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "slideshow": { + "slide_type": "skip" + }, + "tags": [ + "remove-input" + ] + }, + "outputs": [], + "source": [ + "from IPython.display import IFrame\n", + "from IPython.display import Markdown\n", + "# Additional styling ; should be moved into helpers\n", + "from IPython.core.display import display, HTML\n", + "HTML(''.format(open('styler.css').read()))\n", + "Q1 = IFrame('https://app.sli.do/event/0oandysw/embed/polls/bcf12c99-53c2-467c-9635-b6564db67e11', width=450, height=550)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "source": [ + "## Lecture Outline" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "source": [ + "- Introduction (40 mins)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "source": [ + "- Break (10 mins)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "source": [ + "- Course Tools survey (2 mins)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "source": [ + "- Syllabus walk-through (10 minutes)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "source": [ + "- Demo of DATA 530 Lab and GitHub (20 mins)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "source": [ + "## Introduction" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "subslide" + } + }, + "source": [ + "### The Essence of the course\n", + "\n", + "The overall goal of this course is for you to:\n", + "\n", + "**Install, configure, and use a variety of data analysis tools and software packages**\n", + "\n", + "This course covers how to configure data analysis environments, select appropriate tools for particular tasks, read documentation and get help, and use a variety of software packages for data analysis.\n", + "\n", + " - Other courses will build on this course by going deeper into the application of these systems and techniques.\n", + " \n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "subslide" + } + }, + "source": [ + "### Course Objectives\n", + "\n", + "1. Install and setup a variety of software tools and programs used by data analysts" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "source": [ + "2. Perform basic and advanced data analysis and visualization in Excel" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "source": [ + "3. Able to setup IDEs and write small programs in Python and R" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "source": [ + "4. Understand the pros and cons of each tool/software package and criteria to select the best tool for the job" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "subslide" + } + }, + "source": [ + "### Course Goals (for me)\n", + "\n", + "1) Provide the information in a simple, concise, and effective way for learning." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "source": [ + "2) Strive for all students to understand the material and excel at the course." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "source": [ + "3) Be available for questions during class time, office hours, and at other times as needed." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "source": [ + "4) Provide an introduction to a variety of data analysis software and systems." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "source": [ + "5) Emphasize the use of Excel as a easy-to-use, general tool for data analysis." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "subslide" + } + }, + "source": [ + "### Academic Integrity\n", + "\n", + "\n", + "Cheating is strictly prohibited and is taken very seriously by UBC. A guideline to what constitutes cheating:\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "source": [ + "- **Labs**\n", + " - Submitting code produced by others.\n", + " - Working in groups to solve questions and/or comparing answers to questions once they have been solved (except for group assignments).\n", + " - Discussing HOW to solve a particular question instead of WHAT the question involves." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "source": [ + "- **Exams (Quizzes)**\n", + " - DATA 530 and 531 Quizzes are open book\n", + " - No communication about course content is permitted (with classmates, or others)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "subslide" + } + }, + "source": [ + "### How to Excel in this course" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "source": [ + "- **Attend class**\n", + " - If required, Read notes **before** class as preparation and try the questions on your own\n", + " - Participate in class activities and questions (clickers)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "source": [ + "- **Attend and complete all labs**\n", + " - Labs practice the fundamental employable skills as well as being for marks." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "source": [ + "- **Practice on your own. Practice makes perfect.**\n", + " - Do more questions than in the labs.\n", + " - Read the additional reference material and perform practice questions." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "subslide" + } + }, + "source": [ + "### Systems and tools" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "source": [ + "1. Course Material: \n", + " - Canvas, this site, and Github (all are identical)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "source": [ + "2. Marks:\n", + " - Canvas" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "source": [ + "3. Feedback\n", + " - Canvas and (sometimes) Github " + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "source": [ + "4. Hardware\n", + " - Your laptop (mostly)\n", + " - Cloud computing (when needed): https://ubc.syzygy.ca" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "subslide" + } + }, + "source": [ + "### Lab Assignments\n", + "\n", + "- Weekly lab assignments are worth 40% of your overall grade.\n", + "\n", + "- Lab assignments will likely take more than the 1.5 hours of lab time.\n", + "\n", + "- You have until after the following lab to complete each lab.\n", + " - Late labs will not be accepted (except for grace period)\n", + " \n", + "- Lab assignments are done individually but can be worked on collaboratively.\n", + "\n", + "- The lab assignments are critical to learning the material and are designed both to prepare you for the exams and build up your skills!" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "subslide" + } + }, + "source": [ + "### Labs during COVID-19\n", + "\n", + "- Lab sections are 3 hours long, split into two to ensure physical distancing \n", + " - Section 1: 12:30 - 14:00\n", + " - Section 2: 14:00 - 15:30\n", + " \n", + "- If there are 16 people that would like to attend the physical lab, we should split evenly so half are in each section\n", + "\n", + "- Need to coordinate and figure out who would like to attend labs\n", + " - I don't have a good system at the moment, maybe we can brainstorm together?" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "subslide" + } + }, + "source": [ + "### Breakout rooms activity [10 mins]\n", + "\n", + "We will split into breakout rooms for this activity, in groups of about 4\n", + "\n", + "#### Your Task: In your small groups, brainstorm ways to organize \"who goes where, when\".\n", + "\n", + "- Keep in mind that many of us will be attending remotely, and there are timezones to consider!\n", + "- Write your ideas on Slack in the DATA 530 channel - use threads to comment on others' ideas!\n", + "- Consider, \"The Zen of Python\":" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The Zen of Python, by Tim Peters\n", + "\n", + "Beautiful is better than ugly.\n", + "Explicit is better than implicit.\n", + "Simple is better than complex.\n", + "Complex is better than complicated.\n", + "Flat is better than nested.\n", + "Sparse is better than dense.\n", + "Readability counts.\n", + "Special cases aren't special enough to break the rules.\n", + "Although practicality beats purity.\n", + "Errors should never pass silently.\n", + "Unless explicitly silenced.\n", + "In the face of ambiguity, refuse the temptation to guess.\n", + "There should be one-- and preferably only one --obvious way to do it.\n", + "Although that way may not be obvious at first unless you're Dutch.\n", + "Now is better than never.\n", + "Although never is often better than *right* now.\n", + "If the implementation is hard to explain, it's a bad idea.\n", + "If the implementation is easy to explain, it may be a good idea.\n", + "Namespaces are one honking great idea -- let's do more of those!\n" + ] + } + ], + "source": [ + "import this " + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "subslide" + } + }, + "source": [ + "### In-class \"Clicker questions\" AKA Participation\n", + "\n", + "To promote understanding, 10% of your overall grade is allocated to answering in-class questions (called Clickers).\n", + "\n", + "- These questions are answered using [Sli.do](https://sli.do) and you will need to create an account.\n", + "\n", + "- You should download the apps and bookmark the site for convenience\n", + "\n", + "- At different times during all the lectures, questions reviewing material will be asked. Reponses are given using Sli.do polls.\n", + "\n", + "- We will do several of these today to get you familiar with the system" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "subslide" + } + }, + "source": [ + "### Activity: A typical Clicker Sequence\n", + "\n", + "- Part 1: Instructor asks a question and students answer" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "source": [ + "- Part 2: Instructor shows the results (Optional) and opens breakout rooms for students to discuss their choices with others" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "source": [ + " - Part 3: Instructor asks the same question again and we see if there is convergence" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "source": [ + "### Clicker Question Activity [5 mins]" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "slideshow": { + "slide_type": "subslide" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Q1" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "subslide" + } + }, + "source": [ + "#### Results and breakout rooms\n", + "\n", + "(Part 2: Instructor shows the results (Optional) and opens breakout rooms for students to discuss their choices with others" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "subslide" + } + }, + "source": [ + "#### Re-vote and Debrief\n", + "\n", + "(Part 3: Instructor asks the same question again and we see if there is convergence)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "source": [ + "## Break (10 mins)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "source": [ + "## Course Tools Survey (2 mins)" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "IFrame('https://ubc.ca1.qualtrics.com/jfe/form/SV_eboA3fyVCFkhixn',width=750,height=1300)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "source": [ + "## Syllabus walk-through (10 minutes)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "source": [ + "### Content covered\n", + "\n", + "- How learning works\n", + "- Piazza for Q&A, Slack for conversations\n", + "- Canvas structure\n", + "- Course structure\n", + "- Course policies\n", + "- Due dates and grace period (for DATA 530 and 531 only)\n", + "- Quiz policies\n", + "- Labs" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "source": [ + "## Demo of DATA 530 Lab and GitHub (20 mins)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "source": [ + "### Content covered\n", + "\n", + "- Navigating GitHub\n", + "- Uploading files on GitHub\n", + " - Uploading to a specific folder\n", + "- Accepting a lab assignment\n", + "- Cloning a repository (repo)\n", + " - `git clone `\n", + "- Making changes to a local version of a repo\n", + " - `code README.md` and then make changes\n", + "- Commit your changes to the repository\n", + " - `git add -A`\n", + " - `git commit -m \"This is a test commit\"`\n", + "- Pushing the changes above\n", + " - `git push`" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "slideshow": { + "slide_type": "skip" + }, + "tags": [ + "remove-input" + ] + }, + "outputs": [], + "source": [ + "## RISE Template\n", + "\n", + "from traitlets.config.manager import BaseJSONConfigManager\n", + "from pathlib import Path\n", + "path = Path.home() / \".jupyter\" / \"nbconfig\"\n", + "cm = BaseJSONConfigManager(config_dir=str(path))\n", + "tmp = cm.update(\n", + " \"rise\",\n", + " {\n", + " \"theme\": \"sky\", # https://revealjs.com/themes/\n", + " \"transition\": \"fade\",\n", + " \"start_slideshow_at\": \"selected\",\n", + " \"autolaunch\": False,\n", + " \"width\": \"100%\",\n", + " \"height\": \"100%\",\n", + " \"header\": \"\",\n", + " \"footer\":\"\",\n", + " \"scroll\": True,\n", + " \"enable_chalkboard\": True,\n", + " \"slideNumber\": True,\n", + " \"center\": False,\n", + " \"controlsLayout\": \"edges\",\n", + " \"slideNumber\": True,\n", + " \"hash\": True,\n", + " }\n", + " )" + ] + } + ], + "metadata": { + "celltoolbar": "Tags", + "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.8.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/notes/demo01/lecture3.md b/notes/demo01/lecture3.md new file mode 100644 index 0000000..643f4d1 --- /dev/null +++ b/notes/demo01/lecture3.md @@ -0,0 +1,13 @@ +# Introduction to Microsoft Excel + + + +## Excel file using in lecture. + +You can download the [Excel file used in lecture here](https://github.com/firasm/bits/raw/master/sales.xlsx) + +## Sli.do Polls + +You can go to [https://sli.do/data530](https://sli.do/data301) in a new tab or use the embedded poll here: + + \ No newline at end of file diff --git a/notes/demo01/styler.css b/notes/demo01/styler.css new file mode 100644 index 0000000..cc13360 --- /dev/null +++ b/notes/demo01/styler.css @@ -0,0 +1,63 @@ +/*.container { width:100% !important; }*/ + +div.prompt {display:none} + +div.output_subarea {max-width:100%} + +/* These below are from the altair_talk css */ + +/* ---------- markdown cells + */ +body.rise-enabled div.inner_cell>div.text_cell_render.rendered_html { + font-size: 100%; +} + + +/* ---------- code blocks inside markdown + i.e. within ``` lines, or 4-space indented + */ +div.inner_cell>div.text_cell_render.rendered_html>pre { + margin: 0px; +} + +/* ----------- code to remove space above markdown headers + */ +div.inner_cell>div.text_cell_render.rendered_html h1 { + margin-top: 0px; +} +div.inner_cell>div.text_cell_render.rendered_html h2 { + margin-top: 0px; +} +div.inner_cell>div.text_cell_render.rendered_html h3 { + margin-top: 0px; +} +div.inner_cell>div.text_cell_render.rendered_html h4 { + margin-top: 0px; +} + +div.inner_cell>div.text_cell_render.rendered_html>pre>code { + font-size: 70%; +} + +/* ---------- tables (from SO) + */ +.rendered_html table, .rendered_html th, .rendered_html tr, .rendered_html td { + font-size: 120%; +} + +/* ---------- Left part of code cells + from this SO answer: https://stackoverflow.com/a/47263575; + /* Narrow the prompts */ +div.prompt_container { + min-width: 5ex; +} +/* Hide prompts altogether for non-conda cells */ +.cell:not(.code_cell) .prompt { + display: none; +} +/* ---------- Width of cells + */ +.container { + width:95% !important; +} + diff --git a/notes/demo02/demo02_summary.md b/notes/demo02/demo02_summary.md new file mode 100755 index 0000000..6a1a964 --- /dev/null +++ b/notes/demo02/demo02_summary.md @@ -0,0 +1,44 @@ +(page_topic2_demo)= +Week 2 Summary +======================= + +## How this course is organized + +Hello students! Welcome to Week 2 - this week we will begin the physics part of our class! + +
+ +
+ +## How to watch flipped lecture videos + +
+ +
+ +Optional: [Showing the differences between a Traditional and a Flipped Classroom](https://www.youtube.com/watch?v=yzMFdDT6FSA). + + +## List of things to do this week + +Below is a list of things you need to do this week, links to where you can do them, as well as roughly the order you should do it. +Note that these are just SUGGESTIONS and you are by no means required to them this way. +I have put the labs at the end, but if your lab section is earlier in the week, you may want to shift things around. + + + + + + + + +```{tip} +Normally the homework for this week would be due by Thursday at 18:00, but this week because there are/were textbook issues, I have extended this to next Thursday () +``` + + + + + + + \ No newline at end of file diff --git a/notes/demo02/homework.md b/notes/demo02/homework.md new file mode 100644 index 0000000..3f48661 --- /dev/null +++ b/notes/demo02/homework.md @@ -0,0 +1,11 @@ +# Homework + +````{card} + +This week the homework assignment is on Chapter 3, and is posted on Mastering physics. + +```{button-link} https://portal.mypearson.com +Mastering Physics + +``` +```` \ No newline at end of file diff --git a/notes/demo02/lab.md b/notes/demo02/lab.md new file mode 100644 index 0000000..8742d5c --- /dev/null +++ b/notes/demo02/lab.md @@ -0,0 +1,12 @@ +# Lab + +````{card} + +The lab details are posted on the lab course. + +```{button-link} https://canvas.ubc.ca/courses/66799 +Physics 111 Lab Course +:type: url +:classes: btn-outline-primary btn-block stretched-link text-dark +``` +```` \ No newline at end of file diff --git a/notes/demo02/learninglogs.md b/notes/demo02/learninglogs.md new file mode 100644 index 0000000..b6e624e --- /dev/null +++ b/notes/demo02/learninglogs.md @@ -0,0 +1,16 @@ +# Learning Logs + +This week's learning log assignment is now posted on Canvas: + +https://canvas.ubc.ca/courses/63995/quizzes/255367 + +````{card} + +This week's learning log assignment is now posted on Canvas. + +```{button-link} https://canvas.ubc.ca/courses/63995/quizzes/255367 +Learning Log #1 +:type: url +:classes: btn-outline-primary btn-block stretched-link text-dark +``` +```` diff --git a/notes/demo02/readings.md b/notes/demo02/readings.md new file mode 100644 index 0000000..019ec25 --- /dev/null +++ b/notes/demo02/readings.md @@ -0,0 +1,16 @@ +# Readings + +This week the readings assignments are: + + + +````{card} + +If you have access to the eText, click here to access the eText. + +```{button-link} https://portal.mypearson.com +Pearson eText +:type: url +:classes: btn-outline-warning btn-block stretched-link text-dark +``` +```` \ No newline at end of file diff --git a/notes/demo02/test.md b/notes/demo02/test.md new file mode 100644 index 0000000..73e1301 --- /dev/null +++ b/notes/demo02/test.md @@ -0,0 +1,13 @@ +# Test 1 + +````{card} + +This week you will have your first Test, and it will mostly be on the contents of Chapter 2 and 3. +Remember that Test 1 will be available starting at Thursday at 6:00 PM PDT and will remain available until Saturday at 6:00 PM. +You will have 60 minutes to complete the test. + +```{button-link} https://canvas.ubc.ca/courses/63995/assignments +Test 1 on Canvas + +``` +```` \ No newline at end of file diff --git a/notes/demo02/videos.md b/notes/demo02/videos.md new file mode 100644 index 0000000..0cdfe4c --- /dev/null +++ b/notes/demo02/videos.md @@ -0,0 +1,196 @@ +# Videos + +Below are the assigned videos for this week. +The videos are collapsible so once you're done with one, you can move to the next one. +In the sidebar on the right, you can use the checklists to keep track of what's done. + +````{margin} +```{admonition} Checklist of items +:class: tip sticky + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` +```` + +## Summary of Calculus from Crash Course Physics (Optional but recommended) + +```{dropdown} Derivatives + :class-container: sd-shadow-lg + :color: primary + +
+ +
+``` + +```{dropdown} Integrals + :class-container: sd-shadow-lg + :color: primary + +
+ +
+``` + +## Required Videos + +```{dropdown} 1. Vectors and 2D Motion + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + +```{dropdown} 2. Introduction to Tip-to-Tail Vector Addition, Vectors and Scalars + :class-container: sd-shadow-lg + :color: primary + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0049_lecture_notes_-_introduction_to_tip-to-tail_vector_addition_vectors_and_scalars.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/vectors-and-scalars.html) +``` + +```{dropdown} 3. Introductory Tip-to-Tail Vector Addition Problem + :class-container: sd-shadow-lg + :color: primary + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0008_lecture_notes_-_introduction_to_velocity_and_speed.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/tip-to-tail-vector-addition.html) +``` + +```{dropdown} 4. Introduction to Vector Components + :class-container: sd-shadow-lg + :color: primary + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0052_lecture_notes_-_introduction_to_vector_components.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/vector-components.html) +``` + +```{dropdown} 5. Introduction to Component Vectors and Unit Vectors + :class-container: sd-shadow-lg + :color: primary + +
+ +
+``` + +```{dropdown} 6. Introductory Vector Addition Problem using Component Vectors + :class-container: sd-shadow-lg + :color: primary + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0053_lecture_notes_-_introductory_vector_addition_problem_using_component_vectors_also_0054.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/introductory-vector-addition-problem.html) +``` + +```{dropdown} 7. A Visually Complicated Vector Addition Problem using Component Vectors + :class-container: sd-shadow-lg + :color: primary + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0055_lecture_notes_-_a_visually_complicated_vector_addition_problem_using_component_vectors.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/complicated-vector-addition.html) +``` + +```{dropdown} 8. An Introductory Vector Addition Problem using Unit Vectors + :class-container: sd-shadow-lg + :color: primary + +
+ +
+``` +```{dropdown} 9. Introduction to the R Position Vector by way of an Example Problem + :class-container: sd-shadow-lg + :color: primary + +
+ +
+``` + +```{dropdown} 10. Using the R Position Vector to find Velocity and Acceleration - Example Problem + :class-container: sd-shadow-lg + :color: primary + +
+ +
+``` + +```{dropdown} 11. How to use Cardinal Directions with Vectors + :class-container: sd-shadow-lg + :color: primary + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0051_lecture_notes_-_how_to_use_cardinal_directions_with_vectors.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/cardinal-directions.html) +``` + +## Optional Videos + +The videos below are relevant to the subject material, but are not required for Physics 111. + +```{dropdown} 12. Using a Data Table to Make Vector Addition Problems Easier + :class-container: sd-shadow-lg + :color: primary + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/_0053_lecture_notes_-_introductory_vector_addition_problem_using_component_vectors_also_0054.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/data-table.html) + +``` \ No newline at end of file diff --git a/notes/demo03/demo03_summary.md b/notes/demo03/demo03_summary.md new file mode 100755 index 0000000..432bdfd --- /dev/null +++ b/notes/demo03/demo03_summary.md @@ -0,0 +1,92 @@ +# Readings + +This week we will discuss the famous Hamlet soliloquy, also known as Act III Scene I. +Your task is to annotate the words with your commentary, and come to class ready to discuss and act out this scene in your interpretation. + +> To be, or not to be: that is the question: +> +> Whether 'tis nobler in the mind to suffer +> +> The slings and arrows of outrageous fortune, +> +> Or to take arms against a sea of troubles, +> +> And by opposing end them? To die: to sleep; +> +> No more; and by a sleep to say we end +> +> The heart-ache and the thousand natural shocks +> +> That flesh is heir to, 'tis a consummation +> +> Devoutly to be wish'd. To die, to sleep; +> +> To sleep: perchance to dream: ay, there's the rub; +> +> For in that sleep of death what dreams may come +> +> When we have shuffled off this mortal coil, +> +> Must give us pause: there's the respect +> +> That makes calamity of so long life; +> +> For who would bear the whips and scorns of time, +> +> The oppressor's wrong, the proud man's contumely, +> +> The pangs of despised love, the law's delay, +> +> The insolence of office and the spurns +> +> That patient merit of the unworthy takes, +> +> When he himself might his quietus make +> +> With a bare bodkin? who would fardels bear, +> +> To grunt and sweat under a weary life, +> +> But that the dread of something after death, +> +> The undiscover'd country from whose bourn +> +> No traveller returns, puzzles the will +> +> And makes us rather bear those ills we have +> +> Than fly to others that we know not of? +> +> Thus conscience does make cowards of us all; +> +> And thus the native hue of resolution +> +> Is sicklied o'er with the pale cast of thought, +> +> And enterprises of great pith and moment +> +> With this regard their currents turn awry, +> +> And lose the name of action.—Soft you now! +> +> The fair Ophelia! Nymph, in thy orisons +> +> Be all my sins remember'd. +> + +```{dropdown} Benedict Cumberbatch as Hamlet + :class-container: sd-shadow-lg + :color: primary + +
+ +
+``` + +```{dropdown} Mel Gibson as Hamlet + :class-container: sd-shadow-lg + :color: primary +
+ +
+``` \ No newline at end of file diff --git a/notes/demo04/demo04_summary.md b/notes/demo04/demo04_summary.md new file mode 100644 index 0000000..12b3e02 --- /dev/null +++ b/notes/demo04/demo04_summary.md @@ -0,0 +1,20 @@ +# Lecture + +This week in the lecture we will go through the following worksheet and clicker questions. + +## Video on Drawing Lewis Structures + +
+ +
+ +## PhET Simulation + + + +## Drawing Molecules with MarvinJS + +More [details about MarvinJS here](https://chemaxon.com/products/marvin-js) + + + + +[Download the Slides from today](https://github.com/ubc-cs/cpsc203/raw/main/files/Lec01Intro.pdf) + +## Important links for today: + +- [Canvas](https://canvas.ubc.ca/courses/130127) +- [PrairieLearn](https://canvas.ubc.ca/courses/130127/external_tools/48751) +- [Markdown Tutorial](https://commonmark.org/help/tutorial/) + +## Acknowledgements + +Slides for {{ COURSE_CODE }} were developed and created by [Dr. Cinda Heeren](https://www.cs.ubc.ca/people/cinda-heeren). The current iteration of the course resulted in minor adaptations and updates, but by in large, full credit of these slides belongs to Dr. Cinda Heeren. \ No newline at end of file diff --git a/notes/week01/class1B.md b/notes/week01/class1B.md new file mode 100644 index 0000000..d6d761d --- /dev/null +++ b/notes/week01/class1B.md @@ -0,0 +1,157 @@ +# Class Meeting 1B + +Today we will be learning about the Terminal! + +
+ +
+ +CommandPrompt + +CommandPrompt + +## Announcements + +[Download the (logistics) Slides from today](https://github.com/ubc-cs/cpsc203/raw/main/files/Lec02Terminal.pdf) + +## Introduction to the Terminal (Command Line) + +If you would like some additional notes and a much deeper explanation of the command line (also known as the Terminal), I suggest the notes from [Software Carpentry](https://swcarpentry.github.io/shell-novice/)! +They are excellent. + +In particular, I suggest "Introducing the shell", "Navigating Files and Directories", and "Working with Files and Directories" + +### What is the Command Line? + +The **command line** is the text interface to the computer that accepts commands that the computer will execute. +These commands include: + +- starting programs +- navigating directories and manipulating files +- searching, sorting, and editing text files +- system and environment configuration + +### Why learn command line? + +The command line is the text interface to the computer. +Understanding the command line allows you to interact with the computer in ways that you often cannot with the graphical user interface (GUI). + +The command line is commonly used for scripting and automation of tasks and when accessing remote systems. +It will also be useful to run programs that make use of the command line (eg. github). + +### Why use command line? + +The command line is part of the operating system (OS), which is software that manages your computer including all devices and programs. + +- Common operating systems include Windows, Mac OS, and Linux/Unix. +- Some commands will be OS specific + +You might be wondering why we would ever prefer command line over using the graphical user interface (GUI). +- Certain tools may only be available to command line. +- Sometimes command line is faster. + +### Command Line on Windows + +The command line on Windows dates back to the original Microsoft operating system called DOS (Disk Operating System) in 1981. + +This command line interface is still part of all modern Windows operating systems and is accessible as the "Command Prompt". + +**I am requiring you use GitBash instead of the default Windows Command Prompt.** + +### Windows Terminal + +This is what the GitBash "Terminal" looks like. From here on out, whenever we say "Terminal", we mean "GitBash on Windows", "Terminal on macOS and Ubuntu" + +CommandPrompt + +- The directory separator is a forward slash `/` for Macs/Ubuntu, and the opposite pointing slash on Windows `\` +- However if you use GitBash, this should preserve your sanity and you should be able to use forward slash on Windows as well +- In fact, many of the macOS/Ubuntu commands will also work in GitBash, but for completeness we will also share the other commands + +Image source: [Git for windows](https://gitforwindows.org) + +### Mac OS Command Line + +The command line for Mac OS uses the same commands as Linux. It can be opened using Finder then Utilities then Terminal. + +CommandPrompt + +Alternatively, we could type Cmd + spacebar, then type “Terminal" and press ENTER. + +### Entering Commands + +Enter a command at a prompt. The prompt may be a > or a $ or customized by the user. + +Press ENTER to execute the command. + +Commands are case-insensitive on both Mac/Linux and Windows. +Running commands CommandPrompt + +Here are some useful Terminal Commands + +- [`cd`](https://man7.org/linux/man-pages/man1/cd.1p.html) : change directory +- [`pwd`](https://man7.org/linux/man-pages/man1/pwd.1.html) : print working directory +- [`mkdir`](https://man7.org/linux/man-pages/man1/mkdir.1.html): make directory +- [`mkdir -p`](https://man7.org/linux/man-pages/man1/mkdir.1.html): make directory and create (p)arent directories if they do not exist +- [`ls`](https://man7.org/linux/man-pages/man1/ls.1.html): list directory contents +- [`rm`](https://man7.org/linux/man-pages/man1/rm.1.html): Delete a file +- [`rm -r`](https://man7.org/linux/man-pages/man1/rm.1.html): Delete a directory +- [`touch`](https://man7.org/linux/man-pages/man1/touch.1.html): create an empty file with a specific name + +### Special Commands + +These are commands that will require some extra configuration to use. +In this workspace, we've set them up for you already, but just be warned, these will not be available by default on all machines. + +- [`tree`](https://linux.die.net/man/1/tree) : print out a directory tree view of files and folders +- `code`: edit the file in the VS Code editor + + +### Learning Intentions: Terminal + +By the end of class, and after deliberate practice you should be able to: + +- Define command line and list some of its uses +- Explain the purpose of an operating system +- Know how to open the command line window on macOS and Windows +- Enter commands in the Terminal and stop them +- Define: file system, folder, file +- Explain the difference between an absolute and relative path +- Use command line shortcuts to save time +- Be able to cancel a command (Ctrl+C) + +## Tips and Tricks with the Terminal + +- Use the `pwd` command to find out where you are in the Terminal at any point! + +- Use "Up" and "Down" arrow keys to cycle through previously used commands. + - This is a huge time saver! + +- Use Tab completion!! + - Press tab to see available options + +- Use `*` to autocomplete partial matches + +### Conclusion + +- The command line is the text interface to the computer that accepts commands that the computer will execute including running programs, manipulating files, and running scripts. + +- The command line allows for automation and more control than may be available in the user interface. It may also be the only way to interact with the machine if connecting via SSH. + +- The command environment allows for redirecting the standard input and output using input/output redirection and pipes. + +- You need to **PRACTICE PRACTICE PRACTICE** working in the Terminal: to get yourself used to it, I suggest not using the Finder/Explorer on your computer and use the Terminal for everything. + + - `open` will open a file in the default application on macOS. + - `open .` will open the file in Finder. + - `explorer.exe .` will open the folder in Explorer + +## Guide to your operating system (Optional) + +For macOS users, [here's a video](https://www.youtube-nocookie.com/embed/egK5BKEn87c) that shows you a little about some features on your computer. + +https://youtu.be/RX160bcMFuA + +## Guide to the operating system for Windows 10 users + +For Windows 10 users, [here's a video](https://www.youtube-nocookie.com/embed/RX160bcMFuA) that shows you a little about some features on your computer. \ No newline at end of file diff --git a/notes/week01/images/Terminal.png b/notes/week01/images/Terminal.png new file mode 100644 index 0000000..81c570d Binary files /dev/null and b/notes/week01/images/Terminal.png differ diff --git a/notes/week01/images/running_commands.png b/notes/week01/images/running_commands.png new file mode 100644 index 0000000..4e5d26a Binary files /dev/null and b/notes/week01/images/running_commands.png differ diff --git a/notes/week01/videos.md b/notes/week01/videos.md new file mode 100644 index 0000000..e674e07 --- /dev/null +++ b/notes/week01/videos.md @@ -0,0 +1,70 @@ +# Videos + +Below are the assigned videos for this week. +The videos are collapsible so once you're done with one, you can move to the next one. + +```{dropdown} +:open: + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0007_lecture_notes_-_displacement_versus_distance.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/introduction-to-displacement.html) + +``` + +```{dropdown} +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0008_lecture_notes_-_introduction_to_velocity_and_speed.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/introduction-to-velocity-and-speed.html) + +``` + +```{dropdown} + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0009_lecture_notes_-_average_velocity_example_problem_with_three_velocities.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/average-velocity-example-problem-with-three-velocities.html) + +``` + +```{dropdown} + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0010_lecture_notes_-_example_problem_-_velocity_and_speed_are_different.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/example-problem-velocity-and-speed-are-different.html) + +``` + +```{dropdown} + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0011_lecture_notes_-_understanding_walking_and_graphing_position_as_a_function_of_time.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/understanding-and-walking-graphs-of-position-as-a-function-of-time.html) + +``` + +```{dropdown} + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0012_lecture_notes_-_example_problem_-_finding_necessary_pole_position_speed.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/example-problem-finding-average-speed-for-pole-position-ndash-not-as-easy-as-you-think.html) + +``` \ No newline at end of file diff --git a/notes/week01/week01_summary.md b/notes/week01/week01_summary.md new file mode 100755 index 0000000..7caae9d --- /dev/null +++ b/notes/week01/week01_summary.md @@ -0,0 +1,10 @@ +(page_topic1)= +Week 1 +======================= + +This week we will be doing course introductions, I will be showing you how to navigate the course website, and how the course is set up. +In terms of content, we will learn Markdown together, and then start getting familiar with some course tools and Git. + +## Course Introductions! + +Hello, my name is Firas Moosvi and I am your instructor for {{ COURSE_CODE }}! \ No newline at end of file diff --git a/notes/week02/Untitled.ipynb b/notes/week02/Untitled.ipynb new file mode 100644 index 0000000..ff78054 --- /dev/null +++ b/notes/week02/Untitled.ipynb @@ -0,0 +1,91 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "e5b54578-7c6a-4878-af1f-6c5fc116e305", + "metadata": {}, + "outputs": [], + "source": [ + "def is_prime(number):\n", + " \"\"\"Check if a number is a prime number.\"\"\"\n", + " if number <= 1:\n", + " return False\n", + " elif number == 2:\n", + " return True\n", + " elif number % 2 == 0:\n", + " return False\n", + " else:\n", + " # Check for factors up to the square root of the number\n", + " for i in range(3, int(number**0.5) + 1, 2):\n", + " if number % i == 0:\n", + " return False\n", + " return True" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "609dcd87-a079-46e5-8063-d53404523941", + "metadata": {}, + "outputs": [], + "source": [ + "p = [-50,10,50,17,19,11,541]" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "a09bd645-ae4f-42dc-ac19-338f4e4bcc80", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "False\n", + "False\n", + "False\n", + "True\n", + "True\n", + "True\n", + "True\n" + ] + } + ], + "source": [ + "for n in p:\n", + " print(is_prime(n))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d6d84710-19b1-49ec-9e0f-9a7c6388806a", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "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.10.2" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/notes/week02/class2A.ipynb b/notes/week02/class2A.ipynb new file mode 100644 index 0000000..74f517f --- /dev/null +++ b/notes/week02/class2A.ipynb @@ -0,0 +1,3336 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "slide" + }, + "user_expressions": [] + }, + "source": [ + "# Class 2A: Review of Programming in Python I\n", + "\n", + "We will begin soon!\n", + "\n", + "\n", + "\n", + "
\n", + "
\n", + "
\n", + " Photo by Christina Morillo from Pexels\n", + "
\n", + "\n", + "[Download the (logistics) Slides from today](https://github.com/ubc-cs/cpsc203/raw/main/files/Lec03PythonReview.pdf)\n", + "\n", + "
\n", + " Firas Moosvi\n", + "
" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "slide" + }, + "tags": [] + }, + "source": [ + "**Note: Some images may look slightly different than yours as the software gets more polished and icons/user interfaces change, but this should give you a general gist of the essential things.**\n", + "\n", + "" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "subslide" + } + }, + "source": [ + "" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "subslide" + } + }, + "source": [ + "" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "subslide" + } + }, + "source": [ + "" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "subslide" + } + }, + "source": [ + "" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "subslide" + } + }, + "source": [ + "" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "subslide" + } + }, + "source": [ + "" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "source": [ + "## Part 1: Introduction (30 mins)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "source": [ + "## Outline:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "source": [ + "- Part 1: Review of Python\n", + " - Basic datatypes\n", + " - Lists and tuples\n", + " - Break (5 min)\n", + " - String methods\n", + " - Dictionaries\n", + " - Conditionals" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "\n", + "\n", + "## Datatypes in Python\n", + "\n", + "Python has several data types available.\n", + "The diagram below [from Geeks for Geeks](https://www.geeksforgeeks.org/python-data-types/) shows a nice summary of how the datatypes are classified, and examples of each.\n", + "You'll notice that some types are in a class of their own (`dict`, `set`, `bool`) whereas other ones are similar but have distinguishing features (`list`/`tuple`/`str` and `int`/`float` etc...).\n", + "\n", + "" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Common built-in Python data types\n", + "\n", + "| English name | Type name | Description | Example |\n", + "| :--- | :--- | :--- | :--- |\n", + "| integer | `int` | positive/negative whole numbers | `42` |\n", + "| floating point number | `float` | real number in decimal form | `3.14159` |\n", + "| boolean | `bool` | true or false | `True` |\n", + "| string | `str` | text | `\"I Can Has Cheezburger?\"` |\n", + "| list | `list` | a collection of objects - mutable & ordered | `['Ali','Xinyi','Miriam']` |\n", + "| tuple | `tuple` | a collection of objects - immutable & ordered | `('Thursday',6,9,2018)` |\n", + "| dictionary | `dict` | mapping of key-value pairs | `{'name':'DSCI','code':511,'credits':2}` |\n", + "| none | `NoneType` | represents no value | `None` |" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Variables and Values\n", + "\n", + "- A **value** is a piece of data that a computer program works with such as a number or text. \n", + "- There are different **types** of values: `42` is an integer and `\"Hello!\"` is a string. \n", + "- A **variable** is a name that refers to a value. \n", + " - In mathematics and statistics, we usually use variables names like $x$ and $y$. \n", + " - In Python, we can use any word as a variable name (as long as it starts with a letter and is not a [reserved word](https://docs.python.org/3.3/reference/lexical_analysis.html#keywords) in Python such as `for`, `while`, `class`, `lambda`, etc.). \n", + "- And we use the **assignment operator** `=` to assign a value to a variable.\n", + "\n", + "- See the [Python 3 documentation](https://docs.python.org/3/library/stdtypes.html) for a summary of the standard built-in Python datatypes. \n", + "- See [Think Python (Chapter 2)](http://greenteapress.com/thinkpython/html/thinkpython003.html) for a discussion of variables, expressions and statements in Python." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Numeric Types" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "x = 42.5" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "float" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(x)" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "5\n" + ] + } + ], + "source": [ + "x = 5\n", + "print(x)" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "3" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "x=5\n", + "x-2" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [], + "source": [ + "pi = 3.14159" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3.14159\n" + ] + } + ], + "source": [ + "print(pi)" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "float" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(pi)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Arithmetic Operators\n", + "\n", + "The syntax for the arithmetic operators are:\n", + "\n", + "| Operator | Description |\n", + "| :---: | :---: |\n", + "| `+` | addition |\n", + "| `-` | subtraction |\n", + "| `*` | multiplication |\n", + "| `/` | division |\n", + "| `**` | exponentiation |\n", + "| `//` | integer division |\n", + "| `%` | modulo |\n", + "\n", + "Let's apply these operators to numeric types and observe the results." + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "15" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "1 + 2 + 3 + 4 + 5" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0.30000000000000004" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "0.1 + 0.2" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "```{tip}\n", + "From Firas: This is floating point arithmetic. For an explanation of what's going on, [see this tutorial](https://docs.python.org/3/tutorial/floatingpoint.html).\n", + "```" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "6.28318" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "2 * 3.14159" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1024" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "2**10" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "int" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(2**10)" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1024.0" + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "2.0**10" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": {}, + "outputs": [], + "source": [ + "int_2 = 2" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [], + "source": [ + "float_2 = 2.0" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [], + "source": [ + "float_2_again = 2." + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "53.5" + ] + }, + "execution_count": 28, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "107 / 2" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "53" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "107 // 2 # \"integer division\" - always rounds down" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1" + ] + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "101 % 2 # \"101 mod 2\", or the remainder when 101 is divided by 2" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Strings\n", + "\n", + "- Text is stored as a type called a string. \n", + "- We think of a string as a sequence of characters. \n", + "- We write strings as characters enclosed with either:\n", + " - single quotes, e.g., `'Hello'` \n", + " - double quotes, e.g., `\"Goodbye\"`\n", + " - triple single quotes, e.g., `'''Yesterday'''`\n", + " - triple double quotes, e.g., `\"\"\"Tomorrow\"\"\"`" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "metadata": {}, + "outputs": [], + "source": [ + "my_name = \"Firas Moosvi\"" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Firas Moosvi\n" + ] + } + ], + "source": [ + "print(my_name)" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "str" + ] + }, + "execution_count": 41, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(my_name)" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "metadata": {}, + "outputs": [], + "source": [ + "course = 'CPSC 203'" + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "CPSC 203\n" + ] + } + ], + "source": [ + "print(course)" + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "str" + ] + }, + "execution_count": 44, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(course)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "If the string contains a quotation or apostrophe, we can use double quotes or triple quotes to define the string." + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "metadata": {}, + "outputs": [], + "source": [ + "sentence = \"It's a rainy day.\"" + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "It's a rainy day.\n" + ] + } + ], + "source": [ + "print(sentence)" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "str" + ] + }, + "execution_count": 47, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(sentence)" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "metadata": {}, + "outputs": [], + "source": [ + "saying = '''They say: \n", + "\"It's a rainy day!\"'''" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "They say: \n", + "\"It's a rainy day!\"\n" + ] + } + ], + "source": [ + "print(saying)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Sequence Type\n", + "\n", + "This datatype contains three subtypes and serves as a good way to \"hold/store stuff\" - a container.\n", + "\n", + "Each subtype has their own unique distinguishing features but they can all hold items of any type (and multiple types).\n", + "\n", + "Below are the main differences between lists, tuples, and sets:\n", + "\n", + "- `list`: items are ordered, and **can** be edited, changed after insertion.\n", + "- `set`: items are unique, but not ordered. Items cannot be replaced or changed, but can be removed or added.\n", + "- `tuple`: items are ordered, but cannot be replaced or changed once created.\n" + ] + }, + { + "cell_type": "code", + "execution_count": 74, + "metadata": {}, + "outputs": [], + "source": [ + "mylist = ['one','two','apples','three','apples',600.50, 50, 'banana']" + ] + }, + { + "cell_type": "code", + "execution_count": 75, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{50, 600.5, 'apples', 'banana', 'one', 'three', 'two'}" + ] + }, + "execution_count": 75, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "set(mylist)" + ] + }, + { + "cell_type": "code", + "execution_count": 76, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "('one', 'two', 'apples', 600.5)" + ] + }, + "execution_count": 76, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "mytuple = ('one','two','apples', 600.5)\n", + "\n", + "mytuple" + ] + }, + { + "cell_type": "code", + "execution_count": 78, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "('one', 'two', 'apples', 600.5, 'blagreenck')" + ] + }, + "execution_count": 78, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "mytuple +('blagreenck',)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Sets\n", + "\n", + "- Another built-in Python data type is the `set`, which stores an _un-ordered_ list of _unique_ items." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{2, 3, 5, 11}" + ] + }, + "execution_count": 154, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "s = {2,3,5,11}\n", + "s" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 155, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "{1,2,3} == {3,2,1}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 156, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "[1,2,3] == [3,2,1]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{2, 3, 5, 11}" + ] + }, + "execution_count": 159, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "s.add(2) # does nothing\n", + "s" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "s[0]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Above: throws an error because elements are not ordered." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Boolean\n", + "\n", + "- The Boolean (`bool`) type has two values: `True` and `False`. " + ] + }, + { + "cell_type": "code", + "execution_count": 50, + "metadata": {}, + "outputs": [], + "source": [ + "the_truth = True" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n" + ] + } + ], + "source": [ + "print(the_truth)" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "bool" + ] + }, + "execution_count": 52, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(the_truth)" + ] + }, + { + "cell_type": "code", + "execution_count": 53, + "metadata": {}, + "outputs": [], + "source": [ + "lies = False" + ] + }, + { + "cell_type": "code", + "execution_count": 54, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "False\n" + ] + } + ], + "source": [ + "print(lies)" + ] + }, + { + "cell_type": "code", + "execution_count": 55, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "bool" + ] + }, + "execution_count": 55, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(lies)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Comparison Operators\n", + "\n", + "Compare objects using comparison operators. The result is a Boolean value.\n", + "\n", + "| Operator | Description |\n", + "| :---: | :--- |\n", + "| `x == y ` | is `x` equal to `y`? |\n", + "| `x != y` | is `x` not equal to `y`? |\n", + "| `x > y` | is `x` greater than `y`? |\n", + "| `x >= y` | is `x` greater than or equal to `y`? |\n", + "| `x < y` | is `x` less than `y`? |\n", + "| `x <= y` | is `x` less than or equal to `y`? |\n", + "| `x is y` | is `x` the same object as `y`? |" + ] + }, + { + "cell_type": "code", + "execution_count": 56, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 56, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "2 < 3" + ] + }, + { + "cell_type": "code", + "execution_count": 57, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 57, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "\"Data Science\" != \"Deep Learning\"" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 58, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "2.0 == \"two\"" + ] + }, + { + "cell_type": "code", + "execution_count": 59, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 59, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "2 == 2.0" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Note: we will discuss `is` next week." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Operators on Boolean values.\n", + "\n", + "| Operator | Description |\n", + "| :---: | :--- |\n", + "|`x and y`| are `x` and `y` both true? |\n", + "|`x or y` | is at least one of `x` or `y` true? |\n", + "| `not x` | is `x` false? | " + ] + }, + { + "cell_type": "code", + "execution_count": 60, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 60, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "True and True" + ] + }, + { + "cell_type": "code", + "execution_count": 61, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 61, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "True and False" + ] + }, + { + "cell_type": "code", + "execution_count": 62, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 62, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "False or False" + ] + }, + { + "cell_type": "code", + "execution_count": 63, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 63, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(\"Python 2\" != \"Python 3\") and (2 <= 3)" + ] + }, + { + "cell_type": "code", + "execution_count": 64, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 64, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "not True" + ] + }, + { + "cell_type": "code", + "execution_count": 65, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 65, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "not not True" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### NoneType\n", + "\n", + "- `NoneType` is its own type in Python.\n", + "- It only has one possible value, `None`\n", + "- You may have seen similar things in other languages, like `null` in Java, etc." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [], + "source": [ + "x = None" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "None\n" + ] + } + ], + "source": [ + "print(x)" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "NoneType" + ] + }, + "execution_count": 33, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(x)" + ] + }, + { + "cell_type": "code", + "execution_count": 149, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 149, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "bool(None)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Dictionaries\n", + "\n", + "Dictionaries are **awesome**! We'll look at those in a lot more detail soon." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Break!" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Dictionaries (10 min)\n", + "\n", + "A dictionary is a mapping between key-values pairs." + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": {}, + "outputs": [], + "source": [ + "house = {'bedrooms': 3, \n", + " 'bathrooms': 2, \n", + " 'city': 'Vancouver', \n", + " 'price': 2499999, \n", + " 'date_sold': (1,3,2015)}\n", + "\n", + "condo = {'bedrooms' : 2, \n", + " 'bathrooms': 1, \n", + " 'city' : 'Burnaby', \n", + " 'price' : 699999, \n", + " 'date_sold': (27,8,2011)\n", + " }" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'bedrooms': 3,\n", + " 'bathrooms': 2,\n", + " 'city': 'Vancouver',\n", + " 'price': 2499999,\n", + " 'date_sold': (1, 3, 2015)}" + ] + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "house" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can access a specific field of a dictionary with square brackets:" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "2499999" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "house['price']" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'Burnaby'" + ] + }, + "execution_count": 32, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "condo['city']" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can also edit dictionaries (they are mutable):" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'bedrooms': 2,\n", + " 'bathrooms': 1,\n", + " 'city': 'Burnaby',\n", + " 'price': 5,\n", + " 'date_sold': (27, 8, 2011)}" + ] + }, + "execution_count": 33, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "condo['price'] = 5 # price already in the dict\n", + "condo" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": {}, + "outputs": [], + "source": [ + "condo['flooring'] = \"wood\"" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'bedrooms': 2,\n", + " 'bathrooms': 1,\n", + " 'city': 'Burnaby',\n", + " 'price': 5,\n", + " 'date_sold': (27, 8, 2011),\n", + " 'flooring': 'wood'}" + ] + }, + "execution_count": 35, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "condo" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can delete fields entirely (though I rarely use this):" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": {}, + "outputs": [], + "source": [ + "del condo[\"city\"]" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'bedrooms': 2,\n", + " 'bathrooms': 1,\n", + " 'price': 5,\n", + " 'date_sold': (27, 8, 2011),\n", + " 'flooring': 'wood'}" + ] + }, + "execution_count": 37, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "condo" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": {}, + "outputs": [], + "source": [ + "condo[5] = 443345" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'bedrooms': 2,\n", + " 'bathrooms': 1,\n", + " 'price': 5,\n", + " 'date_sold': (27, 8, 2011),\n", + " 'flooring': 'wood',\n", + " 5: 443345}" + ] + }, + "execution_count": 39, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "condo" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'bedrooms': 2,\n", + " 'bathrooms': 1,\n", + " 'price': 5,\n", + " 'date_sold': (27, 8, 2011),\n", + " 'flooring': 'wood',\n", + " 5: 443345,\n", + " (1, 2, 3): 777}" + ] + }, + "execution_count": 40, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "condo[(1,2,3)] = 777\n", + "condo" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": {}, + "outputs": [ + { + "ename": "KeyError", + "evalue": "'nothere'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m/var/folders/64/bfv2dn992m17r4ztvfrt93rh0000gn/T/ipykernel_6265/2495379980.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mcondo\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"nothere\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;31mKeyError\u001b[0m: 'nothere'" + ] + } + ], + "source": [ + "condo[\"nothere\"]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "A sometimes useful trick about default values:" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "2" + ] + }, + "execution_count": 42, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "condo[\"bedrooms\"]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "is shorthand for" + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "2" + ] + }, + "execution_count": 43, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "condo.get(\"bedrooms\")" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "NoneType" + ] + }, + "execution_count": 45, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(condo.get('nothere'))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "With this syntax you can also use default values:" + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "2" + ] + }, + "execution_count": 46, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "condo.get(\"bedrooms\", \"unknown\")" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'FREEZER'" + ] + }, + "execution_count": 49, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "condo.get(\"fireplaces\", \"FREEZER\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- A common operation is finding the maximum dictionary key by value.\n", + "- There are a few ways to do this, see [this StackOverflow page](https://stackoverflow.com/questions/268272/getting-key-with-maximum-value-in-dictionary).\n", + "- One way of doing it:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "max(word_lengths, key=word_lengths.get)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We saw `word_lengths.get` above - it is saying that we should call this function on each key of the dict to decide how to sort." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Indexing Sequences (Lists and Tuples) (20 min)\n", + "\n", + "- Lists and tuples allow us to store multiple things (\"elements\") in a single object.\n", + "- The elements are _ordered_.\n", + "- We can access values inside a list, tuple, or string using the bracket syntax. \n", + "- Python uses zero-based indexing, which means the first element of the list is in position 0, not position 1." + ] + }, + { + "cell_type": "code", + "execution_count": 87, + "metadata": {}, + "outputs": [], + "source": [ + "my_list = [1, 2, \"THREE\", 4, 0.5]" + ] + }, + { + "cell_type": "code", + "execution_count": 88, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[1, 2, 'THREE', 4, 0.5]\n" + ] + } + ], + "source": [ + "print(my_list)" + ] + }, + { + "cell_type": "code", + "execution_count": 89, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "list" + ] + }, + "execution_count": 89, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(my_list)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "You can get the length of the list with `len`:" + ] + }, + { + "cell_type": "code", + "execution_count": 90, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "5" + ] + }, + "execution_count": 90, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len(my_list)" + ] + }, + { + "cell_type": "code", + "execution_count": 91, + "metadata": {}, + "outputs": [], + "source": [ + "today = (1, 2, \"THREE\", 4, 0.5)" + ] + }, + { + "cell_type": "code", + "execution_count": 92, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(1, 2, 'THREE', 4, 0.5)\n" + ] + } + ], + "source": [ + "print(today)" + ] + }, + { + "cell_type": "code", + "execution_count": 93, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "tuple" + ] + }, + "execution_count": 93, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(today)" + ] + }, + { + "cell_type": "code", + "execution_count": 94, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "5" + ] + }, + "execution_count": 94, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len(today)" + ] + }, + { + "cell_type": "code", + "execution_count": 95, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[1, 2, 'THREE', 4, 0.5]" + ] + }, + "execution_count": 95, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "my_list" + ] + }, + { + "cell_type": "code", + "execution_count": 96, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1" + ] + }, + "execution_count": 96, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "my_list[0]" + ] + }, + { + "cell_type": "code", + "execution_count": 97, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0.5" + ] + }, + "execution_count": 97, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "my_list[4]" + ] + }, + { + "cell_type": "code", + "execution_count": 98, + "metadata": {}, + "outputs": [ + { + "ename": "IndexError", + "evalue": "list index out of range", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[98], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mmy_list\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m5\u001b[39;49m\u001b[43m]\u001b[49m\n", + "\u001b[0;31mIndexError\u001b[0m: list index out of range" + ] + } + ], + "source": [ + "my_list[5]" + ] + }, + { + "cell_type": "code", + "execution_count": 99, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0.5" + ] + }, + "execution_count": 99, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "today[4]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can use negative indices to count backwards from the end of the list." + ] + }, + { + "cell_type": "code", + "execution_count": 101, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[1, 2, 'THREE', 4, 0.5]" + ] + }, + "execution_count": 101, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "my_list" + ] + }, + { + "cell_type": "code", + "execution_count": 102, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0.5" + ] + }, + "execution_count": 102, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "my_list[-1]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We use the colon `:` to access a subsequence. This is called \"slicing\"." + ] + }, + { + "cell_type": "code", + "execution_count": 103, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[2, 'THREE', 4]" + ] + }, + "execution_count": 103, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "my_list[1:4]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Above: note that the start is inclusive and the end is exclusive.\n", + "- So `my_list[1:3]` fetches elements 1 and 2, but not 3.\n", + "- In other words, it gets the 2nd and 3rd elements in the list." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can omit the start or end:" + ] + }, + { + "cell_type": "code", + "execution_count": 104, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[1, 2, 'THREE']" + ] + }, + "execution_count": 104, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "my_list[:3]" + ] + }, + { + "cell_type": "code", + "execution_count": 105, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[4, 0.5]" + ] + }, + "execution_count": 105, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "my_list[3:]" + ] + }, + { + "cell_type": "code", + "execution_count": 106, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[1, 2, 'THREE', 4, 0.5]" + ] + }, + "execution_count": 106, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "my_list[:] # *almost* same as my_list - more details next week" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Strings behave the same as lists and tuples when it comes to indexing and slicing." + ] + }, + { + "cell_type": "code", + "execution_count": 107, + "metadata": {}, + "outputs": [], + "source": [ + "alphabet = \"abcdefghijklmnopqrstuvwxyz\"" + ] + }, + { + "cell_type": "code", + "execution_count": 108, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'a'" + ] + }, + "execution_count": 108, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "alphabet[0]" + ] + }, + { + "cell_type": "code", + "execution_count": 109, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'z'" + ] + }, + "execution_count": 109, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "alphabet[-1]" + ] + }, + { + "cell_type": "code", + "execution_count": 110, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'x'" + ] + }, + "execution_count": 110, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "alphabet[-3]" + ] + }, + { + "cell_type": "code", + "execution_count": 111, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'abcde'" + ] + }, + "execution_count": 111, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "alphabet[:5]" + ] + }, + { + "cell_type": "code", + "execution_count": 112, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'mnopqrst'" + ] + }, + "execution_count": 112, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "alphabet[12:20]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### List Methods\n", + "\n", + "- A list is an object and it has methods for interacting with its data. \n", + "- For example, `list.append(item)` appends an item to the end of the list. \n", + "- See the documentation for more [list methods](https://docs.python.org/3/tutorial/datastructures.html#more-on-lists)." + ] + }, + { + "cell_type": "code", + "execution_count": 113, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[2, 3, 5, 7, 11]" + ] + }, + "execution_count": 113, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "primes = [2,3,5,7,11]\n", + "primes" + ] + }, + { + "cell_type": "code", + "execution_count": 114, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "5" + ] + }, + "execution_count": 114, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len(primes)" + ] + }, + { + "cell_type": "code", + "execution_count": 115, + "metadata": {}, + "outputs": [], + "source": [ + "primes.append(13)" + ] + }, + { + "cell_type": "code", + "execution_count": 116, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[2, 3, 5, 7, 11, 13]" + ] + }, + "execution_count": 116, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "primes" + ] + }, + { + "cell_type": "code", + "execution_count": 117, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "6" + ] + }, + "execution_count": 117, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len(primes)" + ] + }, + { + "cell_type": "code", + "execution_count": 118, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "13" + ] + }, + "execution_count": 118, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "max(primes)" + ] + }, + { + "cell_type": "code", + "execution_count": 119, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "2" + ] + }, + "execution_count": 119, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "min(primes)" + ] + }, + { + "cell_type": "code", + "execution_count": 120, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "41" + ] + }, + "execution_count": 120, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sum(primes)" + ] + }, + { + "cell_type": "code", + "execution_count": 121, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[1, 2, 3, 'Hello', 7]" + ] + }, + "execution_count": 121, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "w =[1,2,3] + [\"Hello\", 7]\n", + "w" + ] + }, + { + "cell_type": "code", + "execution_count": 122, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "list" + ] + }, + "execution_count": 122, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(w)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Mutable vs. Immutable Types\n", + "\n", + "- Strings and tuples are immutable types which means they cannot be modified. \n", + "- Lists are mutable and we can assign new values for its various entries. \n", + "- This is the main difference between lists and tuples." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "names_list = [\"Indiana\",\"Fang\",\"Linsey\"]\n", + "names_list" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "names_list[0] = \"Cool guy\"\n", + "names_list" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "names_tuple = (\"Indiana\",\"Fang\",\"Linsey\")\n", + "names_tuple" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "names_tuple[0] = \"Not cool guy\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Same goes for strings. Once defined we cannot modifiy the characters of the string." + ] + }, + { + "cell_type": "code", + "execution_count": 127, + "metadata": {}, + "outputs": [], + "source": [ + "my_name = \"Firas\"" + ] + }, + { + "cell_type": "code", + "execution_count": 128, + "metadata": {}, + "outputs": [ + { + "ename": "TypeError", + "evalue": "'str' object does not support item assignment", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[128], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mmy_name\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m-\u001b[39;49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m]\u001b[49m \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mq\u001b[39m\u001b[38;5;124m'\u001b[39m\n", + "\u001b[0;31mTypeError\u001b[0m: 'str' object does not support item assignment" + ] + } + ], + "source": [ + "my_name[-1] = 'q'" + ] + }, + { + "cell_type": "code", + "execution_count": 129, + "metadata": {}, + "outputs": [], + "source": [ + "x = ([1,2,3],5)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "x[1] = 7" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "x" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "x[0][1] = 4" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "x" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## String Methods (5 min)\n", + "\n", + "- There are various useful string methods in Python." + ] + }, + { + "cell_type": "code", + "execution_count": 130, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "HOW ARE YOU TODAY?\n" + ] + } + ], + "source": [ + "all_caps = \"HOW ARE YOU TODAY?\"\n", + "print(all_caps)" + ] + }, + { + "cell_type": "code", + "execution_count": 131, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'how are you today?'" + ] + }, + "execution_count": 131, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "new_str = all_caps.lower()\n", + "new_str" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Note that the method lower doesn't change the original string but rather returns a new one.\n" + ] + }, + { + "cell_type": "code", + "execution_count": 132, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'HOW ARE YOU TODAY?'" + ] + }, + "execution_count": 132, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "all_caps" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "There are *many* string methods. Check out the [documentation](https://docs.python.org/3/library/stdtypes.html#string-methods)." + ] + }, + { + "cell_type": "code", + "execution_count": 133, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['HOW', 'ARE', 'YOU', 'TODAY?']" + ] + }, + "execution_count": 133, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "all_caps.split()" + ] + }, + { + "cell_type": "code", + "execution_count": 134, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "3" + ] + }, + "execution_count": 134, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "all_caps.count(\"O\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "One can explicitly cast a string to a list:" + ] + }, + { + "cell_type": "code", + "execution_count": 135, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['H',\n", + " 'O',\n", + " 'W',\n", + " ' ',\n", + " 'A',\n", + " 'R',\n", + " 'E',\n", + " ' ',\n", + " 'Y',\n", + " 'O',\n", + " 'U',\n", + " ' ',\n", + " 'T',\n", + " 'O',\n", + " 'D',\n", + " 'A',\n", + " 'Y',\n", + " '?']" + ] + }, + "execution_count": 135, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "caps_list = list(all_caps)\n", + "caps_list" + ] + }, + { + "cell_type": "code", + "execution_count": 136, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "18" + ] + }, + "execution_count": 136, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len(all_caps)" + ] + }, + { + "cell_type": "code", + "execution_count": 137, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "18" + ] + }, + "execution_count": 137, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len(caps_list)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### String formatting\n", + "\n", + "- Python has a really awesome way of formatting strings by \"filling in the blanks\" and formatting them nicely. \n", + "- There are a few ways of doing this, but [f-strings](https://realpython.com/python-f-strings/) are what I would recommend." + ] + }, + { + "cell_type": "code", + "execution_count": 138, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Hello, my name is Firas. I am 5 years old.\n" + ] + } + ], + "source": [ + "myname = \"Firas\"\n", + "age = 5\n", + "\n", + "new = f\"Hello, my name is {myname}. I am {age} years old.\"\n", + "\n", + "print(new)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Empties" + ] + }, + { + "cell_type": "code", + "execution_count": 139, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[]" + ] + }, + "execution_count": 139, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "lst = list() # empty list\n", + "lst" + ] + }, + { + "cell_type": "code", + "execution_count": 140, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[]" + ] + }, + "execution_count": 140, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "lst = [] # empty list\n", + "lst" + ] + }, + { + "cell_type": "code", + "execution_count": 141, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "()" + ] + }, + "execution_count": 141, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "tup = tuple() # empty tuple\n", + "tup" + ] + }, + { + "cell_type": "code", + "execution_count": 142, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "()" + ] + }, + "execution_count": 142, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "tup = () # empty tuple\n", + "tup" + ] + }, + { + "cell_type": "code", + "execution_count": 143, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{}" + ] + }, + "execution_count": 143, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dic = dict() # empty dict\n", + "dic" + ] + }, + { + "cell_type": "code", + "execution_count": 144, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{}" + ] + }, + "execution_count": 144, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dic = {} # empty dict\n", + "dic" + ] + }, + { + "cell_type": "code", + "execution_count": 145, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "set()" + ] + }, + "execution_count": 145, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "st = set() # emtpy set\n", + "st" + ] + }, + { + "cell_type": "code", + "execution_count": 146, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "dict" + ] + }, + "execution_count": 146, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "st = {} # NOT an empty set!\n", + "type(st)" + ] + }, + { + "cell_type": "code", + "execution_count": 147, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "set" + ] + }, + "execution_count": 147, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "st = {1}\n", + "type(st)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Conditionals (10 min)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- [Conditional statements](https://docs.python.org/3/tutorial/controlflow.html) allow us to write programs where only certain blocks of code are executed depending on the state of the program. \n", + "- Let's look at some examples and take note of the keywords, syntax and indentation. \n", + "- Check out the [Python documentation](https://docs.python.org/3/tutorial/controlflow.html) and [Think Python (Chapter 5)](http://greenteapress.com/thinkpython/html/thinkpython006.html) for more information about conditional execution." + ] + }, + { + "cell_type": "code", + "execution_count": 148, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "That's a great name\n" + ] + } + ], + "source": [ + "name = input(\"What's your name?\")\n", + "\n", + "if name.lower() == 'mike':\n", + " print(\"That's my name too!\")\n", + "elif name.lower() == 'santa':\n", + " print(\"That's a funny name.\")\n", + "elif name.lower() == 'firas':\n", + " print(\"That's a great name\")\n", + "else:\n", + " print(f\"Hello {name}! That's a cool name.\")\n", + "\n", + " print('Nice to meet you!')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The main points to notice:\n", + "\n", + "* Use keywords `if`, `elif` and `else`\n", + "* The colon `:` ends each conditional expression\n", + "* Indentation (by 4 empty space) defines code blocks\n", + "* In an `if` statement, the first block whose conditional statement returns `True` is executed and the program exits the `if` block\n", + "* `if` statements don't necessarily need `elif` or `else`\n", + "* `elif` lets us check several conditions\n", + "* `else` lets us evaluate a default block if all other conditions are `False`\n", + "* the end of the entire `if` statement is where the indentation returns to the same level as the first `if` keyword" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "If statements can also be **nested** inside of one another:" + ] + }, + { + "cell_type": "code", + "execution_count": 68, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "What's your name?Jack\n", + "Hello Jack! That's a cool name.\n", + "Nice to meet you!\n" + ] + } + ], + "source": [ + "name = input(\"What's your name?\")\n", + "\n", + "if name.lower() == 'mike':\n", + " print(\"That's my name too!\")\n", + "elif name.lower() == 'santa':\n", + " print(\"That's a funny name.\")\n", + "else:\n", + " print(\"Hello {0}! That's a cool name.\".format(name))\n", + " if name.lower().startswith(\"super\"):\n", + " print(\"Do you have superpowers?\")\n", + "\n", + "print('Nice to meet you!')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Inline if/else" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } + }, + "outputs": [], + "source": [ + "words = [\"the\", \"list\", \"of\", \"words\"]\n", + "\n", + "x = \"long list\" if len(words) > 10 else \"short list\"\n", + "x" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if len(words) > 10:\n", + " x = \"long list\"\n", + "else:\n", + " x = \"short list\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "x" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Preview: Next Class" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Next class we will look at loops, functions, and error handling. After that, we'll be in business for the rest of the course!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "slideshow": { + "slide_type": "skip" + } + }, + "outputs": [], + "source": [ + "## RISE settings\n", + "\n", + "from IPython.display import IFrame\n", + "\n", + "from traitlets.config.manager import BaseJSONConfigManager\n", + "from pathlib import Path\n", + "\n", + "path = Path.home() / \".jupyter\" / \"nbconfig\"\n", + "cm = BaseJSONConfigManager(config_dir=str(path))\n", + "tmp = cm.update(\n", + " \"rise\",\n", + " {\n", + " \"theme\": \"sky\", # blood is dark, nice\n", + " \"transition\": \"fade\",\n", + " \"start_slideshow_at\": \"selected\",\n", + " \"autolaunch\": False,\n", + " \"width\": \"100%\",\n", + " \"height\": \"100%\",\n", + " \"header\": \"\",\n", + " \"footer\": \"\",\n", + " \"scroll\": True,\n", + " \"enable_chalkboard\": True,\n", + " \"slideNumber\": True,\n", + " \"center\": False,\n", + " \"controlsLayout\": \"edges\",\n", + " \"slideNumber\": True,\n", + " \"hash\": True,\n", + " },\n", + ")" + ] + } + ], + "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.10.2" + }, + "vscode": { + "interpreter": { + "hash": "4a3006030bc8f073e17f416a7c98291111bc2dc23e3286a5e86c679c75d3e5ba" + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/notes/week02/class2B.ipynb b/notes/week02/class2B.ipynb new file mode 100644 index 0000000..87da827 --- /dev/null +++ b/notes/week02/class2B.ipynb @@ -0,0 +1,2477 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "slide" + }, + "user_expressions": [] + }, + "source": [ + "# Class 2B: Review of Programming in Python II\n", + "\n", + "We will begin soon!\n", + "\n", + "\n", + "\n", + "
\n", + "
\n", + "
\n", + " Photo by Christina Morillo from Pexels\n", + "
\n", + "\n", + "[Download the (logistics) Slides from today](https://github.com/ubc-cs/cpsc203/raw/main/files/Lec04PythonReview2.pdf)\n", + "\n", + "
\n", + " Firas Moosvi\n", + "
" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Lecture Outline\n", + "\n", + "- Comments (0 min)\n", + "- Loops\n", + "- Comprehensions\n", + "- Break (5 min)\n", + "- Functions\n", + "- Exceptions\n", + "- Testing\n", + "- Questions and Recap" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Attribution\n", + "\n", + "- The original version of these Python lectures were by [Patrick Walls](https://www.math.ubc.ca/~pwalls/).\n", + "- These lectures were originally delivered by [Mike Gelbart](https://mikegelbart.com) and are [available publicly here](https://www.youtube.com/watch?v=7FLv1ACEl-E&list=PLWmXHcz_53Q26aQzhknaT3zwWvl7w8wQE&index=2)." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Comments in python" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": {}, + "outputs": [], + "source": [ + "x = 1 # 5 + 5 this is a comment" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": {}, + "outputs": [], + "source": [ + "# \"\"\"\n", + "# this is a string, which does nothing\n", + "# and can be used as a comment\n", + "# \"\"\"\n", + "\n", + "7\n", + "\n", + "\n", + "x = 1" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Loops" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Loops allow us to execute a block of code multiple times. \n", + "- We will focus on [`for` loops](https://docs.python.org/3/tutorial/controlflow.html#for-statements)" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'I have 6 apples'" + ] + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "\"I have 5 apples\"\n", + "\"I have 6 apples\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### `for` loops" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The number is 2 its square is 4\n", + "The number is 7 its square is 49\n", + "hallelujah\n", + "The number is -1 its square is 1\n", + "The number is 5 its square is 25\n", + "hallelujah\n" + ] + } + ], + "source": [ + "for n in [2, 7, -1, 5]:\n", + " print(\"The number is\", n, \"its square is\", n**2)\n", + " if n > 2:\n", + " print(\"hallelujah\")\n", + " # this is inside the loop\n", + "# this is outside the loop" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([ 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32,\n", + " 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66,\n", + " 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98])" + ] + }, + "execution_count": 32, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import numpy as np\n", + "np.arange(0,100,2)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The main points to notice:\n", + "\n", + "* Keyword `for` begins the loop\n", + "* Colon `:` ends the first line of the loop\n", + "* We can iterate over any kind of iterable: list, tuple, range, string. In this case, we are iterating over the values in a list\n", + "* Block of code indented is executed for each value in the list (hence the name \"for\" loops, sometimes also called \"for each\" loops)\n", + "* The loop ends after the variable `n` has taken all the values in the list" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'abcdef'" + ] + }, + "execution_count": 33, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "\"abc\" + \"def\"" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Gimme a P!\n", + "Gimme a y!\n", + "Gimme a t!\n", + "Gimme a h!\n", + "Gimme a o!\n", + "Gimme a n!\n", + "\tWhat's that spell?!! Python!\n" + ] + } + ], + "source": [ + "word = \"Python\"\n", + "for letter in word:\n", + " print(\"Gimme a \" + letter + \"!\")\n", + "\n", + "print(\"\\tWhat's that spell?!! \" + word + \"!\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- A very common pattern is to use `for` with `range`. \n", + "- `range` gives you a sequence of integers up to some value." + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0\n", + "1\n", + "2\n", + "3\n", + "4\n", + "5\n", + "6\n", + "7\n", + "8\n", + "9\n" + ] + } + ], + "source": [ + "for i in range(10):\n", + " print(i)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can also specify a start value and a skip-by value with `range`:" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1\n", + "11\n", + "21\n", + "31\n", + "41\n", + "51\n", + "61\n", + "71\n", + "81\n", + "91\n" + ] + } + ], + "source": [ + "for i in range(1,101,10):\n", + " print(i)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can write a loop inside another loop to iterate over multiple dimensions of data. Consider the following loop as enumerating the coordinates in a 3 by 3 grid of points." + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(1, 'a')\n", + "(1, 'b')\n", + "(1, 'c')\n", + "(2, 'a')\n", + "(2, 'b')\n", + "(2, 'c')\n", + "(3, 'a')\n", + "(3, 'b')\n", + "(3, 'c')\n" + ] + } + ], + "source": [ + "for x in [1,2,3]:\n", + " for y in [\"a\",\"b\",\"c\"]:\n", + " print((x,y))" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1 a\n", + "2 b\n", + "3 c\n", + "4 d\n" + ] + }, + { + "ename": "IndexError", + "evalue": "list index out of range", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[38], line 4\u001b[0m\n\u001b[1;32m 2\u001b[0m list_2 \u001b[38;5;241m=\u001b[39m [\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124ma\u001b[39m\u001b[38;5;124m\"\u001b[39m,\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mb\u001b[39m\u001b[38;5;124m\"\u001b[39m,\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mc\u001b[39m\u001b[38;5;124m\"\u001b[39m,\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124md\u001b[39m\u001b[38;5;124m\"\u001b[39m]\n\u001b[1;32m 3\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(\u001b[38;5;241m5\u001b[39m):\n\u001b[0;32m----> 4\u001b[0m \u001b[38;5;28mprint\u001b[39m(list_1[i], \u001b[43mlist_2\u001b[49m\u001b[43m[\u001b[49m\u001b[43mi\u001b[49m\u001b[43m]\u001b[49m)\n", + "\u001b[0;31mIndexError\u001b[0m: list index out of range" + ] + } + ], + "source": [ + "list_1 = [1,2,3,4,5]\n", + "list_2 = [\"a\",\"b\",\"c\",\"d\"]\n", + "for i in range(5):\n", + " print(list_1[i], list_2[i])" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1 a\n", + "2 b\n", + "3 c\n", + "4 d\n" + ] + } + ], + "source": [ + "for i,j in zip(list_1,list_2):\n", + " print(i,j)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can loop through key-value pairs of a dictionary using `.items()`:" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Hello\\nWorld\n" + ] + } + ], + "source": [ + "print(\"Hello\\\\nWorld\")" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Hello \\n\n", + "World\n" + ] + } + ], + "source": [ + "h = \"\"\"Hello \\\\n\n", + "World\"\"\"\n", + "\n", + "print(h)" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "DSCI 521 is awesome\n", + "DSCI 551 is riveting\n", + "DSCI 511 is naptime!\n" + ] + } + ], + "source": [ + "courses = {521 : \"awesome\",\n", + " 551 : \"riveting\",\n", + " 511 : \"naptime!\"}\n", + "\n", + "for course_num, description in courses.items():\n", + " print(\"DSCI\", course_num, \"is\", description)" + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "521 awesome\n", + "551 riveting\n", + "511 naptime!\n" + ] + } + ], + "source": [ + "for course_num,course_desc in courses.items():\n", + " print(course_num, course_desc)\n", + "# print(course_num, courses[course_num])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Above: the general syntax is `for key, value in dictionary.items():`" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### `while` loops\n", + "\n", + "- We can also use a [`while` loop](https://docs.python.org/3/reference/compound_stmts.html#while) to excute a block of code several times. \n", + "- In reality, I rarely use these.\n", + "- Beware! If the conditional expression is always `True`, then you've got an infintite loop! \n", + " - (Use the \"Stop\" button in the toolbar above, or Ctrl-C in the terminal, to kill the program if you get an infinite loop.)" + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "10\n", + "9\n", + "8\n", + "7\n", + "6\n", + "5\n", + "4\n", + "3\n", + "2\n", + "1\n", + "Blast off!\n" + ] + } + ], + "source": [ + "n = 10\n", + "while n > 0:\n", + " print(n)\n", + " n = n - 1\n", + "\n", + "print(\"Blast off!\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Comprehensions\n", + "\n", + "Comprehensions allow us to build lists/sets/dictionaries in one convenient, compact line of code." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### List Comprehensions\n", + "\n", + "List comprehensions are one of my favourite features of Python!" + ] + }, + { + "cell_type": "code", + "execution_count": 50, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[0, 10, 20, 30, 40, 50, 60, 70, 80, 90]" + ] + }, + "execution_count": 50, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "[hh*10 for hh in range(10)]\n" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "metadata": { + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['llo', 'bye', 'the', 'ism']" + ] + }, + "execution_count": 51, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "words = [\"hello\", \"goodbye\", \"the\", \"antidisestablishmentarianism\"]\n", + "\n", + "y = [word[-3:] for word in words] # list comprehension\n", + "y" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "llo\n", + "bye\n", + "the\n", + "ism\n" + ] + } + ], + "source": [ + "for word in words:\n", + " print(word[-3:])" + ] + }, + { + "cell_type": "code", + "execution_count": 53, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['llo', 'bye', 'the', 'ism']" + ] + }, + "execution_count": 53, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "y = list()\n", + "for word in words:\n", + " y.append(word[-3:])\n", + "y" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } + }, + "source": [ + "### Dictionary comprehension" + ] + }, + { + "cell_type": "code", + "execution_count": 54, + "metadata": { + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "{'hello': 5, 'goodbye': 7, 'the': 3, 'antidisestablishmentarianism': 28}" + ] + }, + "execution_count": 54, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "word_lengths = {word : len(word) for word in words} # dictionary comprehension\n", + "word_lengths" + ] + }, + { + "cell_type": "code", + "execution_count": 55, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'hello': 'HELLO',\n", + " 'goodbye': 'GOODBYE',\n", + " 'the': 'THE',\n", + " 'antidisestablishmentarianism': 'ANTIDISESTABLISHMENTARIANISM'}" + ] + }, + "execution_count": 55, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "word_upper = {word : word.upper() for word in words}\n", + "word_upper" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Set Comprehensions" + ] + }, + { + "cell_type": "code", + "execution_count": 56, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'o', 'm', 'e'}\n" + ] + } + ], + "source": [ + "y = {word[-1] for word in words} # set comprehension\n", + "print(y)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Tuple Comprehensions" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Tuple comprehensions actually don't exist! But, you can use generators.\n", + "\n", + "See [this StackOverflow post](https://stackoverflow.com/questions/16940293/why-is-there-no-tuple-comprehension-in-python) for (some fun) details!" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Break (5 min)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "tags": [] + }, + "source": [ + "## Functions\n", + "\n", + "- Define a [**function**](https://docs.python.org/3/tutorial/controlflow.html#defining-functions) to re-use a block of code with different input parameters, also known as **arguments**. \n", + "- For example, define a function called `square` which takes one input parameter `n` and returns the square `n**2`." + ] + }, + { + "cell_type": "code", + "execution_count": 57, + "metadata": {}, + "outputs": [], + "source": [ + "def square(n):\n", + " n_squared = n**2\n", + " return n_squared\n", + "\n", + "# quick test:\n", + "assert square(2) ==4" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "152399025" + ] + }, + "execution_count": 58, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "square(12345)" + ] + }, + { + "cell_type": "code", + "execution_count": 59, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "4" + ] + }, + "execution_count": 59, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "square(2)" + ] + }, + { + "cell_type": "code", + "execution_count": 60, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "10000" + ] + }, + "execution_count": 60, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "square(100)" + ] + }, + { + "cell_type": "code", + "execution_count": 61, + "metadata": {}, + "outputs": [], + "source": [ + "# this will fail \n", + "# square('hello')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "* Begins with `def` keyword, function name, input parameters and then colon (`:`)\n", + "* Function block defined by indentation\n", + "* Output or \"return\" value of the function is given by the `return` keyword" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Side effects\n", + "\n", + "- If a function changes the variables passed into it, then it is said to have **side effects**\n", + "- Example:" + ] + }, + { + "cell_type": "code", + "execution_count": 62, + "metadata": {}, + "outputs": [], + "source": [ + "def silly_sum(sri):\n", + " sri.append(0)\n", + " return sum(sri)" + ] + }, + { + "cell_type": "code", + "execution_count": 63, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "10" + ] + }, + "execution_count": 63, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "silly_sum([1,2,3,4])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Looks good, like it sums the numbers? But wait...\n" + ] + }, + { + "cell_type": "code", + "execution_count": 64, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "10" + ] + }, + "execution_count": 64, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "lst = [1,2,3,4]\n", + "silly_sum(lst)" + ] + }, + { + "cell_type": "code", + "execution_count": 65, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "10" + ] + }, + "execution_count": 65, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "silly_sum(lst)" + ] + }, + { + "cell_type": "code", + "execution_count": 66, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[1, 2, 3, 4, 0, 0]" + ] + }, + "execution_count": 66, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "lst" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- If your function has side effects like this, you must mention it in the documentation (later today).\n", + "- More on how this works next class." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Null return type\n", + "\n", + "If you do not specify a return value, the function returns `None` when it terminates:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def f(x):\n", + " x + 1 # no return!\n", + " if x == 999:\n", + " return\n", + " else:\n", + " return('hello')\n", + "print(f(998))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Designing good functions - DRY principle (15 min)\n", + "\n", + "- DRY: **Don't Repeat Yourself**\n", + "- See [Wikipedia article](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself)\n", + "- Consider the task of, for each element of a list, turning it into a palindrome\n", + " - e.g. \"mike\" --> \"mikeekim\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "names = [\"milad\", \"rodolfo\", \"tiffany\", \"khalad\", \"jeff\", \"christel\",\"firas\"]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "name = \"mike\"\n", + "name[::-1]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "names_backwards = list()\n", + "\n", + "names_backwards.append(names[0] + names[0][::-1])\n", + "names_backwards.append(names[1] + names[1][::-1])\n", + "names_backwards.append(names[2] + names[2][::-1])\n", + "names_backwards.append(names[3] + names[3][::-1])\n", + "names_backwards.append(names[4] + names[4][::-1])\n", + "names_backwards.append(names[5] + names[5][::-1])\n", + "names_backwards.append(names[6] + names[6][::-1])\n", + "\n", + "\n", + "names_backwards" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Above: this is gross, terrible, yucky code\n", + " 1. It only works for a list with 3 elements\n", + " 2. It only works for a list named `names`\n", + " 3. If we want to change its functionality, we need to change 3 similar lines of code (Don't Repeat Yourself!!)\n", + " 4. It is hard to understand what it does just by looking at it" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "names_backwards = list()\n", + "\n", + "for name in names:\n", + " names_backwards.append(name + name[::-1])\n", + " \n", + "names_backwards" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Above: this is slightly better. We have solved problems (1) and (3)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def make_palindromes(names):\n", + " names_backwards = list()\n", + " \n", + " for name in names:\n", + " names_backwards.append(name + name[::-1])\n", + " \n", + " return names_backwards" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "p_name = make_palindromes(names)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for p in p_name:\n", + " print(p.upper())" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Above: this is even better. We have now also solved problem (2), because you can call the function with any list, not just `names`. \n", + "- For example, what if we had multiple _lists_:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "names1 = [\"milad\", \"rodolfo\", \"tiffany\"]\n", + "names2 = [\"Trudeau\", \"Scheer\", \"Singh\", \"Blanchet\", \"May\"]\n", + "names3 = [\"apple\", \"orange\", \"banana\"]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "names_backwards_1 = list()\n", + "\n", + "for name in names1:\n", + " names_backwards_1.append(name + name[::-1])\n", + " \n", + "names_backwards_1" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "names_backwards_2 = list()\n", + "\n", + "for name in names2:\n", + " names_backwards_2.append(name + name[::-1])\n", + " \n", + "names_backwards_2" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "names_backwards_3 = list()\n", + "\n", + "for name in names3:\n", + " names_backwards_3.append(name + name[::-1])\n", + " \n", + "names_backwards_3" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Above: this is very bad also (and imagine if it was 20 lines of code instead of 2). This was problem (2). Our function makes it much better:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "make_palindromes(names1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "make_palindromes(names2)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "make_palindromes(names3)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- You could get even more fancy, and put the lists of names into a list (so you have a list of lists). \n", + "- Then you could loop over the list and call the function each time:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for list_of_names in [names1, names2, names3]:\n", + " print(make_palindromes(list_of_names))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Designing good functions" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- How far you go with this is sort of a matter of personal style, and how you choose to apply the DRY principle: DON'T REPEAT YOURSELF!\n", + "- These decisions are often ambiguous. For example: \n", + " - Should `make_palindromes` be a function if I'm only ever doing it once? Twice?\n", + " - Should the loop be inside the function, or outside?\n", + " - Or should there be TWO functions, one that loops over the other??" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- In my personal opinion, `make_palindromes` does a bit too much to be understandable.\n", + "- I prefer this:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def make_palindrome(name):\n", + " return name + name[::-1]\n", + "\n", + "make_palindrome(\"milad\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- From here, we want to \"apply `make_palindrome` to every element of a list\"\n", + "- It turns out this is an extremely common desire, so Python has built-in functions.\n", + "- One of these is `map`, which we'll cover later. But for now, just a comprehension will do:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "[make_palindrome(name) for name in names]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Other function design considerations:\n", + "\n", + "- Should we print output or produce plots inside or outside functions? \n", + " - I would usually say outside, because this is a \"side effect\" of sorts\n", + "- Should the function do one thing or many things?\n", + " - This is a tough one, hard to answer in general" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Optional & keyword arguments\n", + "\n", + "- Sometimes it is convenient to have _default values_ for some arguments in a function. \n", + "- Because they have default values, these arguments are optional, hence \"optional arguments\"\n", + "- Example:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def repeat_string(s, n=2):\n", + " return s*n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "repeat_string(\"mds\", 2)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "repeat_string(\"mds\", 5)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Sane defaults:\n", + "\n", + "- Ideally, the default should be carefully chosen. \n", + "- Here, the idea of \"repeating\" something makes me think of having 2 copies, so `n=2` feels like a sane default." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Syntax:\n", + "\n", + "- You can have any number of arguments and any number of optional arguments\n", + "- **All the optional arguments must come after the regular arguments\n", + "- The regular arguments are mapped by the order they appear\n", + "- The optional arguments can be specified out of order" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def example(a, b, c=\"DEFAULT\", d=\"DEFAULT\"):\n", + " print(a,b,c,d)\n", + " \n", + "example(1,2,3,4)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Using the defaults for `c` and `d`:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "example(1,2)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Specifying `c` and `d` as **keyword arguments** (i.e. by name):" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "example(1,2,c=3,d=4)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Specifying only one of the optional arguments, by keyword:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "example(1,2,c=3)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Or the other:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "example(1,2,d=4)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Specifying all the arguments as keyword arguments, even though only `c` and `d` are optional:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "example(a=1,b=2,c=3,d=4)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Specifying `c` by the fact that it comes 3rd (I do not recommend this because I find it is confusing):" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "example(1,2,3) " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Specifying the optional arguments by keyword, but in the wrong order (this is also somewhat confusing, but not so terrible - I am OK with it):" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "example(1,2,d=4,c=3) " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Specifying the non-optional arguments by keyword (I am fine with this):" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "example(a=1,b=2)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Specifying the non-optional arguments by keyword, but in the wrong order (not recommended, I find it confusing):" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "example(b=2,a=1)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Specifying keyword arguments before non-keyword arguments (this throws an error):" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "example(a=2,b=1)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- In general, I am used to calling non-optional arguments by order, and optional arguments by keyword.\n", + "- The language allows us to deviate from this, but it can be unnecessarily confusing sometimes." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### `kwargs`:\n", + "\n", + "- You can also call/define functions with `*args` and `**kwargs`; see, e.g. [here](https://realpython.com/python-kwargs-and-args/)\n", + "- Do not instantiate objects in the function definition - see [here](https://docs.python-guide.org/writing/gotchas/) under \"Mutable Default Arguments\"" + ] + }, + { + "cell_type": "code", + "execution_count": 67, + "metadata": {}, + "outputs": [], + "source": [ + "def example(a, b=[]): # don't do this!\n", + " return 0" + ] + }, + { + "cell_type": "code", + "execution_count": 68, + "metadata": {}, + "outputs": [], + "source": [ + "def example(a, b=None): # insted, do this\n", + " if b is None:\n", + " b = []\n", + " return 0" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Anonymous functions (5 min)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "There are two ways to define functions in Python:" + ] + }, + { + "cell_type": "code", + "execution_count": 69, + "metadata": {}, + "outputs": [], + "source": [ + "def add_one(x):\n", + " return x+1" + ] + }, + { + "cell_type": "code", + "execution_count": 70, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "8.2" + ] + }, + "execution_count": 70, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "add_one(7.2)" + ] + }, + { + "cell_type": "code", + "execution_count": 71, + "metadata": {}, + "outputs": [], + "source": [ + "add_one = lambda x: x+1 " + ] + }, + { + "cell_type": "code", + "execution_count": 72, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "function" + ] + }, + "execution_count": 72, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(add_one)" + ] + }, + { + "cell_type": "code", + "execution_count": 73, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "8.2" + ] + }, + "execution_count": 73, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "add_one(7.2)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The two approaches above are identical. The one with `lambda` is called an **anonymous function**.\n", + "\n", + "Some differences:\n", + "\n", + "- anonymous functions can only take up one line of code, so they aren't appropriate in most cases.\n", + "- anonymous functions evaluate to a function (remember, functions are first-class objects) immediate, so we can do weird stuff with them." + ] + }, + { + "cell_type": "code", + "execution_count": 74, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "13" + ] + }, + "execution_count": 74, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(lambda x,y: x+y)(6,7)" + ] + }, + { + "cell_type": "code", + "execution_count": 75, + "metadata": {}, + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'evaluate_function_on_x_plus_1' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[75], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mevaluate_function_on_x_plus_1\u001b[49m(\u001b[38;5;28;01mlambda\u001b[39;00m x: x\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m2\u001b[39m, \u001b[38;5;241m5\u001b[39m)\n", + "\u001b[0;31mNameError\u001b[0m: name 'evaluate_function_on_x_plus_1' is not defined" + ] + } + ], + "source": [ + "evaluate_function_on_x_plus_1(lambda x: x**2, 5)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Above:\n", + "\n", + "- First, `lambda x: x**2` evaluates to a value of type `function`\n", + " - Notice that this function is never given a name - hence \"anonymous functions\" !\n", + "- Then, the function and the integer `5` are passed into `evaluate_function_on_x_plus_1`\n", + "- At which point the anonymous function is evaluated on `5+1`, and we get `36`." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exceptions, `try`/`except` (10 min)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- If something goes wrong, we don't want the code to crash - we want it to **fail gracefully**.\n", + "- In Python, this can be accomplished using `try`/`except`:\n", + "- Here is a basic example:" + ] + }, + { + "cell_type": "code", + "execution_count": 76, + "metadata": {}, + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'this_variable_does_not_exist' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[76], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mthis_variable_does_not_exist\u001b[49m\n", + "\u001b[0;31mNameError\u001b[0m: name 'this_variable_does_not_exist' is not defined" + ] + } + ], + "source": [ + "this_variable_does_not_exist" + ] + }, + { + "cell_type": "code", + "execution_count": 77, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "You did something bad!\n" + ] + } + ], + "source": [ + "try:\n", + " this_variable_does_not_exist\n", + "except:\n", + "# pass\n", + " print(\"You did something bad!\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Python tries to execute the code in the `try` block.\n", + "- If an error is encountered, we \"catch\" this in the `except` block (also called `try`/`catch` in other languages).\n", + "- There are many different error types, or **exceptions** - we saw `NameError` above. " + ] + }, + { + "cell_type": "code", + "execution_count": 78, + "metadata": {}, + "outputs": [ + { + "ename": "ZeroDivisionError", + "evalue": "division by zero", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mZeroDivisionError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[78], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;241;43m5\u001b[39;49m\u001b[38;5;241;43m/\u001b[39;49m\u001b[38;5;241;43m0\u001b[39;49m\n", + "\u001b[0;31mZeroDivisionError\u001b[0m: division by zero" + ] + } + ], + "source": [ + "5/0" + ] + }, + { + "cell_type": "code", + "execution_count": 79, + "metadata": {}, + "outputs": [ + { + "ename": "IndexError", + "evalue": "list index out of range", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[79], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m my_list \u001b[38;5;241m=\u001b[39m [\u001b[38;5;241m1\u001b[39m,\u001b[38;5;241m2\u001b[39m,\u001b[38;5;241m3\u001b[39m]\n\u001b[0;32m----> 2\u001b[0m \u001b[43mmy_list\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m5\u001b[39;49m\u001b[43m]\u001b[49m\n", + "\u001b[0;31mIndexError\u001b[0m: list index out of range" + ] + } + ], + "source": [ + "my_list = [1,2,3]\n", + "my_list[5]" + ] + }, + { + "cell_type": "code", + "execution_count": 80, + "metadata": {}, + "outputs": [ + { + "ename": "IndexError", + "evalue": "list index out of range", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[80], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# (note: this is also valid syntax, just very confusing)\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m \u001b[43m[\u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m2\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m3\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m5\u001b[39;49m\u001b[43m]\u001b[49m\n", + "\u001b[0;31mIndexError\u001b[0m: list index out of range" + ] + } + ], + "source": [ + "# (note: this is also valid syntax, just very confusing)\n", + "[1,2,3][5]" + ] + }, + { + "cell_type": "code", + "execution_count": 81, + "metadata": {}, + "outputs": [ + { + "ename": "TypeError", + "evalue": "'tuple' object does not support item assignment", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[81], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m my_tuple \u001b[38;5;241m=\u001b[39m (\u001b[38;5;241m1\u001b[39m,\u001b[38;5;241m2\u001b[39m,\u001b[38;5;241m3\u001b[39m)\n\u001b[0;32m----> 2\u001b[0m \u001b[43mmy_tuple\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m]\u001b[49m \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m0\u001b[39m\n", + "\u001b[0;31mTypeError\u001b[0m: 'tuple' object does not support item assignment" + ] + } + ], + "source": [ + "my_tuple = (1,2,3)\n", + "my_tuple[0] = 0" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Ok, so there are apparently a bunch of different errors one could run into. \n", + "- With `try`/`except` you can also catch the exception itself:" + ] + }, + { + "cell_type": "code", + "execution_count": 82, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "You did something bad!\n", + "name 'this_variable_does_not_exist' is not defined\n", + "\n" + ] + } + ], + "source": [ + "try:\n", + " this_variable_does_not_exist\n", + "except Exception as ex:\n", + " print(\"You did something bad!\")\n", + " print(ex)\n", + " print(type(ex))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- In the above, we caught the exception and assigned it to the variable `ex` so that we could print it out.\n", + "- This is useful because you can see what the error message would have been, without crashing your program." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- You can also catch specific exceptions types, like so:" + ] + }, + { + "cell_type": "code", + "execution_count": 83, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "You made a name error!\n" + ] + } + ], + "source": [ + "try:\n", + " this_variable_does_not_exist\n", + "except TypeError:\n", + " print(\"You made a type error!\")\n", + "except NameError:\n", + " print(\"You made a name error!\")\n", + "except:\n", + " print(\"You made some other sort of error\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- The final `except` would trigger if the error is none of the above types, so this sort of has an `if`/`elif`/`else` feel to it. \n", + "- There are some extra features, in particular an `else` and `finally` block; if you are interested, see e.g., [here](https://www.w3schools.com/python/python_try_except.asp)." + ] + }, + { + "cell_type": "code", + "execution_count": 84, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "You made some other sort of error\n" + ] + } + ], + "source": [ + "try:\n", + " 5/0\n", + "except TypeError:\n", + " print(\"You made a type error!\")\n", + "except NameError:\n", + " print(\"You made a name error!\")\n", + "except Exception as ex:\n", + " print(\"You made some other sort of error\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Ideally, try to make your `try`/`except` blocks specific, and try not to put more errors inside the `except`... " + ] + }, + { + "cell_type": "code", + "execution_count": 85, + "metadata": {}, + "outputs": [ + { + "ename": "ZeroDivisionError", + "evalue": "division by zero", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[85], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m----> 2\u001b[0m \u001b[43mthis_variable_does_not_exist\u001b[49m\n\u001b[1;32m 3\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m:\n", + "\u001b[0;31mNameError\u001b[0m: name 'this_variable_does_not_exist' is not defined", + "\nDuring handling of the above exception, another exception occurred:\n", + "\u001b[0;31mZeroDivisionError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[85], line 4\u001b[0m\n\u001b[1;32m 2\u001b[0m this_variable_does_not_exist\n\u001b[1;32m 3\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m:\n\u001b[0;32m----> 4\u001b[0m \u001b[38;5;241;43m5\u001b[39;49m\u001b[38;5;241;43m/\u001b[39;49m\u001b[38;5;241;43m0\u001b[39;49m\n", + "\u001b[0;31mZeroDivisionError\u001b[0m: division by zero" + ] + } + ], + "source": [ + "try:\n", + " this_variable_does_not_exist\n", + "except:\n", + " 5/0" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- This is a bit much, but it does happen sometimes :(" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Using `raise`\n", + "\n", + "- You can also write code that raises an exception on purpose, using `raise`" + ] + }, + { + "cell_type": "code", + "execution_count": 86, + "metadata": {}, + "outputs": [], + "source": [ + "def add_one(x):\n", + " return x+1" + ] + }, + { + "cell_type": "code", + "execution_count": 87, + "metadata": {}, + "outputs": [ + { + "ename": "TypeError", + "evalue": "can only concatenate str (not \"int\") to str", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[87], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43madd_one\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mblah\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n", + "Cell \u001b[0;32mIn[86], line 2\u001b[0m, in \u001b[0;36madd_one\u001b[0;34m(x)\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21madd_one\u001b[39m(x):\n\u001b[0;32m----> 2\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mx\u001b[49m\u001b[38;5;241;43m+\u001b[39;49m\u001b[38;5;241;43m1\u001b[39;49m\n", + "\u001b[0;31mTypeError\u001b[0m: can only concatenate str (not \"int\") to str" + ] + } + ], + "source": [ + "add_one(\"blah\")" + ] + }, + { + "cell_type": "code", + "execution_count": 88, + "metadata": {}, + "outputs": [], + "source": [ + "def add_one(x):\n", + " if not isinstance(x, float) and not isinstance(x, int):\n", + " raise Exception(\"Sorry, x must be numeric\")\n", + " \n", + " return x+1" + ] + }, + { + "cell_type": "code", + "execution_count": 89, + "metadata": {}, + "outputs": [ + { + "ename": "Exception", + "evalue": "Sorry, x must be numeric", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mException\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[89], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43madd_one\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mblah\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n", + "Cell \u001b[0;32mIn[88], line 3\u001b[0m, in \u001b[0;36madd_one\u001b[0;34m(x)\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21madd_one\u001b[39m(x):\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(x, \u001b[38;5;28mfloat\u001b[39m) \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(x, \u001b[38;5;28mint\u001b[39m):\n\u001b[0;32m----> 3\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mSorry, x must be numeric\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 5\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m x\u001b[38;5;241m+\u001b[39m\u001b[38;5;241m1\u001b[39m\n", + "\u001b[0;31mException\u001b[0m: Sorry, x must be numeric" + ] + } + ], + "source": [ + "add_one(\"blah\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- This is useful when your function is complicated and would fail in a complicated way, with a weird error message.\n", + "- You can make the cause of the error much clearer to the _caller_ of the function.\n", + "- Thus, your function is more usable this way.\n", + "- If you do this, you should ideally describe these exceptions in the function documentation, so a user knows what to expect if they call your function. " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- You can also raise other types of exceptions, or even define your own exception types, as in lab 2.\n", + "- You can also use `raise` by itself to raise whatever exception was going on:" + ] + }, + { + "cell_type": "code", + "execution_count": 90, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "You did something bad!\n" + ] + }, + { + "ename": "NameError", + "evalue": "name 'this_variable_does_not_exist' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[90], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m----> 2\u001b[0m \u001b[43mthis_variable_does_not_exist\u001b[49m\n\u001b[1;32m 3\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m:\n\u001b[1;32m 4\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mYou did something bad!\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", + "\u001b[0;31mNameError\u001b[0m: name 'this_variable_does_not_exist' is not defined" + ] + } + ], + "source": [ + "try:\n", + " this_variable_does_not_exist\n", + "except:\n", + " print(\"You did something bad!\")\n", + " raise" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Here, the original exception is raised after we ran some other code." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Testing" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### `assert` statements\n", + "\n", + "- `assert` statementS cause your program to fail if the condition is `False`.\n", + "- They can be used as sanity checks for your program.\n", + "- There are more sophisticated way to \"test\" your programs, which we'll discuss in Workflows.\n", + "- The syntax is:\n", + "\n", + "```python\n", + "assert expression , \"Error message if expression is False or raises an error.\"\n", + "```" + ] + }, + { + "cell_type": "code", + "execution_count": 91, + "metadata": {}, + "outputs": [ + { + "ename": "AssertionError", + "evalue": "4 is not equal to 5.", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mAssertionError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[91], line 5\u001b[0m\n\u001b[1;32m 2\u001b[0m b \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m5\u001b[39m\n\u001b[1;32m 4\u001b[0m \u001b[38;5;66;03m# Change this assert statement so a and b is used instead of \"hard-coded 1 and 2\"\u001b[39;00m\n\u001b[0;32m----> 5\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m a \u001b[38;5;241m==\u001b[39m b , \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00ma\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m is not equal to \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mb\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n", + "\u001b[0;31mAssertionError\u001b[0m: 4 is not equal to 5." + ] + } + ], + "source": [ + "a = 4\n", + "b = 5\n", + "\n", + "# Change this assert statement so a and b is used instead of \"hard-coded 1 and 2\"\n", + "assert a == b , f\"{a} is not equal to {b}.\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Systematic Program Design" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "A systematic approach to program design is a general set of steps to follow when writing programs. Our approach includes:\n", + "\n", + "1. Write a stub: a function that does nothing but accept all input parameters and return the correct datatype.\n", + "2. Write tests to satisfy the design specifications.\n", + "3. Outline the program with pseudo-code.\n", + "4. Write code and test frequently.\n", + "5. Write documentation.\n", + "\n", + "The key point: write tests BEFORE you write code.\n", + "\n", + "- You do not have to do this in MDS, but you may find it surprisingly helpful.\n", + "- Often writing tests helps you think through what you are trying to accomplish.\n", + "- It's best to have that clear before you write the actual code." + ] + }, + { + "cell_type": "code", + "execution_count": 105, + "metadata": {}, + "outputs": [], + "source": [ + "# Task: Let's calculate area of a rectangle, given length and width" + ] + }, + { + "cell_type": "code", + "execution_count": 106, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "the area should be : 25 and is 25\n", + "the area should be : 25 and is 25\n" + ] + }, + { + "data": { + "text/plain": [ + "25" + ] + }, + "execution_count": 106, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "def calculate_rectangle_area(length, width):\n", + " \"\"\" Computes the area of a rectangle given a length and a width\n", + " inputs: length (float) and width(float)\n", + " \n", + " oututs: area (float)\n", + " \"\"\"\n", + " \n", + " # Check the inputs\n", + " # check if length and width are floats\n", + " \n", + " # Compute area\n", + " area = length * width\n", + " \n", + " print(f\"the area should be : {length * width} and is {area}\")\n", + " \n", + " return area\n", + "\n", + "assert calculate_rectangle_area(5,5) == 25, \"the function is not quite correct because the area of a 5x5 should be 25.\"\n", + "calculate_rectangle_area(5,5)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Testing woes - false positives\n", + "\n", + "- **Just because all your tests pass, this does not mean your program is correct!!**\n", + "- This happens all the time. How to deal with it?\n", + " - Write a lot of tests!\n", + " - Don't be overconfident, even after writing a lot of tests!" + ] + }, + { + "cell_type": "code", + "execution_count": 101, + "metadata": {}, + "outputs": [], + "source": [ + "def sample_median(x):\n", + " \"\"\"Finds the median of a list of numbers.\"\"\"\n", + " x_sorted = sorted(x)\n", + " return x_sorted[len(x_sorted)//2]\n", + "\n", + "assert sample_median([1,2,3,4,5]) == 3\n", + "assert sample_median([0,0,0,0]) == 0" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Looks good? ... ?\n", + "\n", + "




" + ] + }, + { + "cell_type": "code", + "execution_count": 102, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "2" + ] + }, + "execution_count": 102, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "4//2 \n", + "\n", + "#is equivalent to\n", + "\n", + "int(4/2)" + ] + }, + { + "cell_type": "code", + "execution_count": 103, + "metadata": {}, + "outputs": [ + { + "ename": "AssertionError", + "evalue": "", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mAssertionError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[103], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m sample_median([\u001b[38;5;241m1\u001b[39m,\u001b[38;5;241m2\u001b[39m,\u001b[38;5;241m3\u001b[39m,\u001b[38;5;241m4\u001b[39m]) \u001b[38;5;241m==\u001b[39m \u001b[38;5;241m2.5\u001b[39m\n", + "\u001b[0;31mAssertionError\u001b[0m: " + ] + } + ], + "source": [ + "assert sample_median([1,2,3,4]) == 2.5" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "




" + ] + }, + { + "cell_type": "code", + "execution_count": 100, + "metadata": {}, + "outputs": [], + "source": [ + "assert sample_median([1,3,2]) == 2" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Testing woes - false negatives\n", + "\n", + "- It can also happen, though more rarely, that your tests fail but your program is correct.\n", + "- This means there is something wrong with your test.\n", + "- For example, in the autograding for lab1 this happened to some people, because of tiny roundoff errors." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Corner cases\n", + "\n", + "- A **corner case** is an input that is reasonable but a bit unusual, and may trip up your code.\n", + "- For example, taking the median of an empty list, or a list with only one element. \n", + "- Often it is desirable to add test cases to address corner cases." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "assert sample_median([1]) == 1" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- In this case the code worked with no extra effort, but sometimes we need `if` statements to handle the weird cases.\n", + "- Sometimes we **want** the code to throw an error (e.g. median of an empty list)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Questions and Recap?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "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.10.2" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/notes/week02/classA.md b/notes/week02/classA.md new file mode 100644 index 0000000..db82601 --- /dev/null +++ b/notes/week02/classA.md @@ -0,0 +1,7 @@ +# Class Meeting 1 + +## Slides from Lecture + +Will be available here after the lecture. + + \ No newline at end of file diff --git a/notes/week02/homework.md b/notes/week02/homework.md new file mode 100644 index 0000000..70bc2b8 --- /dev/null +++ b/notes/week02/homework.md @@ -0,0 +1,10 @@ +# Homework + +````{card} +This week the homework assignment is on Chapter 2, and is posted on Mastering physics. + +```{button-link} https://portal.mypearson.com +Mastering Physics + +``` +```` \ No newline at end of file diff --git a/notes/week02/images/JB.key b/notes/week02/images/JB.key new file mode 100644 index 0000000..2899188 Binary files /dev/null and b/notes/week02/images/JB.key differ diff --git a/notes/week02/images/base.png b/notes/week02/images/base.png new file mode 100644 index 0000000..7e0a927 Binary files /dev/null and b/notes/week02/images/base.png differ diff --git a/notes/week02/images/bus_stop.jpg b/notes/week02/images/bus_stop.jpg new file mode 100644 index 0000000..707f70c Binary files /dev/null and b/notes/week02/images/bus_stop.jpg differ diff --git a/notes/week02/images/notebook1.png b/notes/week02/images/notebook1.png new file mode 100644 index 0000000..73b2896 Binary files /dev/null and b/notes/week02/images/notebook1.png differ diff --git a/notes/week02/images/notebook2.png b/notes/week02/images/notebook2.png new file mode 100644 index 0000000..78b537e Binary files /dev/null and b/notes/week02/images/notebook2.png differ diff --git a/notes/week02/images/notebook3.png b/notes/week02/images/notebook3.png new file mode 100644 index 0000000..01b9af4 Binary files /dev/null and b/notes/week02/images/notebook3.png differ diff --git a/notes/week02/images/notebook4.png b/notes/week02/images/notebook4.png new file mode 100644 index 0000000..44df671 Binary files /dev/null and b/notes/week02/images/notebook4.png differ diff --git a/notes/week02/images/notebook5.png b/notes/week02/images/notebook5.png new file mode 100644 index 0000000..887b385 Binary files /dev/null and b/notes/week02/images/notebook5.png differ diff --git a/notes/week02/images/notebook6.png b/notes/week02/images/notebook6.png new file mode 100644 index 0000000..716fb47 Binary files /dev/null and b/notes/week02/images/notebook6.png differ diff --git a/notes/week02/images/notebook7.png b/notes/week02/images/notebook7.png new file mode 100644 index 0000000..12667e0 Binary files /dev/null and b/notes/week02/images/notebook7.png differ diff --git a/notes/week02/images/programming.jpg b/notes/week02/images/programming.jpg new file mode 100644 index 0000000..ba8254e Binary files /dev/null and b/notes/week02/images/programming.jpg differ diff --git a/notes/week02/lab.md b/notes/week02/lab.md new file mode 100644 index 0000000..75a2dce --- /dev/null +++ b/notes/week02/lab.md @@ -0,0 +1,13 @@ +# Lab + + +````{card} + +The lab information for this week is in the Physics 111 Lab canvas course... + +```{button-link} https://canvas.ubc.ca/courses/66799 +Physics 111 Lab Canvas +:type: url +:classes: btn-outline-primary btn-block stretched-link text-dark +``` +```` \ No newline at end of file diff --git a/notes/week02/learninglogs.md b/notes/week02/learninglogs.md new file mode 100644 index 0000000..b6e624e --- /dev/null +++ b/notes/week02/learninglogs.md @@ -0,0 +1,16 @@ +# Learning Logs + +This week's learning log assignment is now posted on Canvas: + +https://canvas.ubc.ca/courses/63995/quizzes/255367 + +````{card} + +This week's learning log assignment is now posted on Canvas. + +```{button-link} https://canvas.ubc.ca/courses/63995/quizzes/255367 +Learning Log #1 +:type: url +:classes: btn-outline-primary btn-block stretched-link text-dark +``` +```` diff --git a/notes/week02/readings.md b/notes/week02/readings.md new file mode 100644 index 0000000..dfb3b0d --- /dev/null +++ b/notes/week02/readings.md @@ -0,0 +1,35 @@ +# Readings + +This week the readings assignments are listed below: + + + + + +````{card} + +If you have access to the eText, click here to access the eText. + +```{button-link} https://portal.mypearson.com +Pearson eText +:type: url +:classes: btn-outline-warning btn-block stretched-link text-dark +``` +```` + +```{dropdown} +:open: +
+ +
+``` \ No newline at end of file diff --git a/notes/week02/rise.css b/notes/week02/rise.css new file mode 100644 index 0000000..c3a7dfb --- /dev/null +++ b/notes/week02/rise.css @@ -0,0 +1,80 @@ +/* ---------- markdown cells + */ +body.rise-enabled div.inner_cell>div.text_cell_render.rendered_html { + font-size: 120%; +} + + +/* ---------- code blocks inside markdown + i.e. within ``` lines, or 4-space indented + */ +div.inner_cell>div.text_cell_render.rendered_html>pre { + margin: 0px; +} + +/* ----------- code to remove space above markdown headers + */ +div.inner_cell>div.text_cell_render.rendered_html h1 { + margin-top: 0px; +} +div.inner_cell>div.text_cell_render.rendered_html h2 { + margin-top: 0px; +} +div.inner_cell>div.text_cell_render.rendered_html h3 { + margin-top: 0px; +} +div.inner_cell>div.text_cell_render.rendered_html h4 { + margin-top: 0px; +} + +div.inner_cell>div.text_cell_render.rendered_html>pre>code { + font-size: 70%; +} + +/* ---------- tables (from SO) + */ +.rendered_html table, .rendered_html th, .rendered_html tr, .rendered_html td { + font-size: 120%; +} + +/* ---------- Left part of code cells + from this SO answer: https://stackoverflow.com/a/47263575; + /* Narrow the prompts */ +div.prompt_container { + min-width: 5ex; +} +/* Hide prompts altogether for non-code cells */ +.cell:not(.code_cell) .prompt { + display: none; +} +/* ---------- Width of cells + */ +.container { + width:95% !important; +} + + +/* ---------- Vertical Whitespace + */ +.vspace { + margin-top:50px; +} +/* +div.cell.code_cell.rendered.selected, { + border-width:10px; + border-style:solid; + border-color:red; +} */ + + +/* Removes the border of cells */ + +div.cell { + border-width:0px; +} + +/* Increases the thickness of the blue and green (whether or not the cell is selected */ + +div.cell.selected:before; .edit_mode div.cell.selected:before { + width: 20px; +} diff --git a/notes/week02/test.md b/notes/week02/test.md new file mode 100644 index 0000000..61b96cb --- /dev/null +++ b/notes/week02/test.md @@ -0,0 +1,13 @@ +# Test 0 + +````{card} + +This week is your first test - it is NOT for marks, but is not optional. +It will cover the course policies and will be timed to give you practice on how the testing system works. +This test will be open to you after the Week 2 lecture. + +```{button-link} https://canvas.ubc.ca/courses/63995/quizzes/256495 +Test0 is available + +``` +```` \ No newline at end of file diff --git a/notes/week02/videos.md b/notes/week02/videos.md new file mode 100644 index 0000000..be8100e --- /dev/null +++ b/notes/week02/videos.md @@ -0,0 +1,55 @@ +# Videos + +Below are the assigned videos for this week. +The videos are collapsible so once you're done with one, you can move to the next one. +In the sidebar on the right, you can use the checklists to keep track of what's done. + +````{margin} +```{admonition} Checklist of items +:class: tip sticky + + + + + + + + +``` +```` + +## Required Videos + +There are no required videos this week! + +## Optional Videos + +```{dropdown} 1. Converting Decimal to Binary + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + +```{dropdown} 2. Converting Binary to Decimal + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + +```{dropdown} 3. More on Time Complexity + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` \ No newline at end of file diff --git a/notes/week02/week02_summary.md b/notes/week02/week02_summary.md new file mode 100755 index 0000000..f92f85b --- /dev/null +++ b/notes/week02/week02_summary.md @@ -0,0 +1,6 @@ +(page_topic2)= +Week 2 +======================= + +This week we will be doing a Python Introduction so that we're all on the same page before we start getting to some programming and design. +In terms of content, we'll learn about Python dataypes, conditionals, loops, functions, and error handling. \ No newline at end of file diff --git a/notes/week03/class3A.md b/notes/week03/class3A.md new file mode 100644 index 0000000..22a9dc6 --- /dev/null +++ b/notes/week03/class3A.md @@ -0,0 +1,23 @@ +# Class Meeting 3A + +Below are the slides from today's class embedded. +Feel free to download them to keep them locally, or leave them archived here and just bookmark them. +We will leave the website open even after the course is over for a reasonable number of years. + +
+ +
+ +[Download the Slides from today](https://github.com/ubc-cs/cpsc203/raw/main/files/Lec05efficiency.pdf) + + + +## Acknowledgements + +Slides for {{ COURSE_CODE }} were developed and created by [Dr. Cinda Heeren](https://www.cs.ubc.ca/people/cinda-heeren). The current iteration of the course resulted in minor adaptations and updates, but by in large, full credit of these slides belongs to Dr. Cinda Heeren. \ No newline at end of file diff --git a/notes/week03/class3B.md b/notes/week03/class3B.md new file mode 100644 index 0000000..4a43481 --- /dev/null +++ b/notes/week03/class3B.md @@ -0,0 +1,23 @@ +# Class Meeting 3B + +Below are the slides from today's class embedded. +Feel free to download them to keep them locally, or leave them archived here and just bookmark them. +We will leave the website open even after the course is over for a reasonable number of years. + +
+ +
+ +[Download the Slides from today](https://github.com/ubc-cs/cpsc203/raw/main/files/Lec06knitting1.pdf) + + + +## Acknowledgements + +Slides for {{ COURSE_CODE }} were developed and created by [Dr. Cinda Heeren](https://www.cs.ubc.ca/people/cinda-heeren). The current iteration of the course resulted in minor adaptations and updates, but by in large, full credit of these slides belongs to Dr. Cinda Heeren. \ No newline at end of file diff --git a/notes/week03/homework.md b/notes/week03/homework.md new file mode 100644 index 0000000..3f48661 --- /dev/null +++ b/notes/week03/homework.md @@ -0,0 +1,11 @@ +# Homework + +````{card} + +This week the homework assignment is on Chapter 3, and is posted on Mastering physics. + +```{button-link} https://portal.mypearson.com +Mastering Physics + +``` +```` \ No newline at end of file diff --git a/notes/week03/lab.md b/notes/week03/lab.md new file mode 100644 index 0000000..75a2dce --- /dev/null +++ b/notes/week03/lab.md @@ -0,0 +1,13 @@ +# Lab + + +````{card} + +The lab information for this week is in the Physics 111 Lab canvas course... + +```{button-link} https://canvas.ubc.ca/courses/66799 +Physics 111 Lab Canvas +:type: url +:classes: btn-outline-primary btn-block stretched-link text-dark +``` +```` \ No newline at end of file diff --git a/notes/week03/learninglogs.md b/notes/week03/learninglogs.md new file mode 100644 index 0000000..623e811 --- /dev/null +++ b/notes/week03/learninglogs.md @@ -0,0 +1,66 @@ +# Learning Logs + +This week's learning log assignment will be posted on Canvas by Thursday. + +Here are the questions you will be asked to answer in the learning logs. + +## Task 1: Test Reflection + +This week you will have your first real test in Physics 111 ! +I want you to complete this reflection **after** you finish your test so you can reflect on your experience properly. +You will not receive your test grade until after the learning log is due - this is intentional. + +Q1.1 - How did you prepare for the test (your answers are not graded, so there is no need to lie or exaggerate!) ? Answer in one or two sentences. + +Q1.2 - Do you feel that your preparation helped you on the test this week? Answer in one or two sentences. + +Q1.3 - Will you do anything differently (preparation-wise) for the next tests? Answer in one or two sentences. + +Q1.4 - Select a question from the test that you know you got wrong and do ONE of three things: + +A) explain the misconception that you had that caused you to get the question wrong. + +B) solve the question (or one like it) that you got wrong - the exact numbers or the details of the question do not matter, a similar conceptual question is sufficient. You can attach a picture, or write it in text. + +C) You can skip this question if you do not feel like you got a question wrong. + +Q1.5 - Do you plan to take the Bonus-Test next week to improve your mark? Answer in one or two sentences. + +Q1.6 - Is there anything else you want me to know about your test ? Answer in one or two sentences. + +Q1.7 - What score do you think you got on this test? + +## Task 2: Renew your vows + +Each week, I am asking you to type out the integrity pledge, letter by letter, so you understand how important it is to me that you maintain your academic integrity as you go through this course. + + + +## Task 3: Well-being check + +One of my goals this year is to help you (as best I can) manage your stress and anxieties by "measuring it" on a weekly basis and intervening or making suggestions during our weekly class meeting. +This is an exciting time for all of you as many of you are starting your undergraduate studies. +With this new excitement, you may be feeling additional stress and anxiety as you learn to manage this new life with its drastic changes, that too in the middle of a pandemic. +In terms of providing support for you as an instructor I’d like for us to measure/rate your anxiety and stress levels - I understand that you may not know what level of stress and/or anxiety is appropriate at this level of your education so feel free to note that! + +Q1: On a scale of 1-10, rate your CURRENT level of anxiety and stress: + +Anxiety: 1-10 +Stress: 1-10 + +Q2: On a scale of 1-10, rate WHERE DO YOU THINK YOUR level of anxiety and stress SHOULD BE: + +Anxiety: 1-10 +Stress: 1-10 + +Q3: Is there anything else you would like to tell me? + +[Open Text] + +I’ll do what I can within my role as an instructor, in terms of workload and due dates. +Part of undergraduate life and healthy living is finding ways to manage your stress and anxiety in a manner that is effective for you - this will look different for each person! +If you want to explore additional resources, start with the ones listed at [UBCV Health and wellbeing](https://students.ubc.ca/health) and see if the tips there work for you! + +Finally, remember (from the course syllabus): as I'm sure you're aware, *there is a global pandemic* happening right now and we could all use some extra compassion and humanity. +If you're going through something that is affecting you (course or otherwise), you are always welcome to come and talk to me about it. +If I am not able to help you myself, then I can probably direct you to the right person or resource. diff --git a/notes/week03/lecture.md b/notes/week03/lecture.md new file mode 100644 index 0000000..ac35a3f --- /dev/null +++ b/notes/week03/lecture.md @@ -0,0 +1,15 @@ +# Lecture + +This week we will do go over some key clicker questions from Chapter 2 and 3 in preparation for the test later today. + +## Sli.do Polls + +You can go to [https://sli.do/physics111](https://app.sli.do/event/lk89xpvr/live/polls) in a new tab or use the embedded poll here: + + + +## Slides from Lecture + +Will be available here after the lecture. + + \ No newline at end of file diff --git a/notes/week03/readings.md b/notes/week03/readings.md new file mode 100644 index 0000000..019ec25 --- /dev/null +++ b/notes/week03/readings.md @@ -0,0 +1,16 @@ +# Readings + +This week the readings assignments are: + + + +````{card} + +If you have access to the eText, click here to access the eText. + +```{button-link} https://portal.mypearson.com +Pearson eText +:type: url +:classes: btn-outline-warning btn-block stretched-link text-dark +``` +```` \ No newline at end of file diff --git a/notes/week03/test.md b/notes/week03/test.md new file mode 100644 index 0000000..73e1301 --- /dev/null +++ b/notes/week03/test.md @@ -0,0 +1,13 @@ +# Test 1 + +````{card} + +This week you will have your first Test, and it will mostly be on the contents of Chapter 2 and 3. +Remember that Test 1 will be available starting at Thursday at 6:00 PM PDT and will remain available until Saturday at 6:00 PM. +You will have 60 minutes to complete the test. + +```{button-link} https://canvas.ubc.ca/courses/63995/assignments +Test 1 on Canvas + +``` +```` \ No newline at end of file diff --git a/notes/week03/videos.md b/notes/week03/videos.md new file mode 100644 index 0000000..e47f457 --- /dev/null +++ b/notes/week03/videos.md @@ -0,0 +1,80 @@ +# Videos + +Below are the assigned videos for this week. +The videos are collapsible so once you're done with one, you can move to the next one. +In the sidebar on the right, you can use the checklists to keep track of what's done. + +````{margin} +```{admonition} Checklist of items +:class: tip sticky + + + + + + + + + + + +``` +```` + +## Required Videos + +Below are the assigned videos for this week. + +### Videos before Tuesday's class + +```{dropdown} 1. Handcraft + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + +```{dropdown} 2. Quantifying the Task + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + +```{dropdown} 3. Colour Representation + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + +### Videos before Thursday's class + +```{dropdown} 4. Handcraft Program Design + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + +```{dropdown} 5. Classes in Python + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` \ No newline at end of file diff --git a/notes/week03/week03_summary.md b/notes/week03/week03_summary.md new file mode 100755 index 0000000..0a20a5c --- /dev/null +++ b/notes/week03/week03_summary.md @@ -0,0 +1,5 @@ +(page_topic3)= +Week 3 +======================= + +This week we be learning about Python classes, knitting, the `dataclass`, and other fun things! \ No newline at end of file diff --git a/notes/week04/class4A.md b/notes/week04/class4A.md new file mode 100644 index 0000000..22d1457 --- /dev/null +++ b/notes/week04/class4A.md @@ -0,0 +1,23 @@ +# Class Meeting 4A + +Below are the slides from today's class embedded. +Feel free to download them to keep them locally, or leave them archived here and just bookmark them. +We will leave the website open even after the course is over for a reasonable number of years. + +
+ +
+ +[Download the Slides from today](https://github.com/ubc-cs/cpsc203/raw/main/files/Lec07knitting2.pdf) + + + +## Acknowledgements + +Slides for {{ COURSE_CODE }} were developed and created by [Dr. Cinda Heeren](https://www.cs.ubc.ca/people/cinda-heeren). The current iteration of the course resulted in minor adaptations and updates, but by in large, full credit of these slides belongs to Dr. Cinda Heeren. \ No newline at end of file diff --git a/notes/week04/class4B.md b/notes/week04/class4B.md new file mode 100644 index 0000000..699bfaa --- /dev/null +++ b/notes/week04/class4B.md @@ -0,0 +1,23 @@ +# Class Meeting 4B + +We're going to change things up for today and switch today's class to a Review and catch-up class with no new content. + +
+ +
+ +[Download the Slides from today](https://github.com/ubc-cs/cpsc203/raw/main/files/Lec08_Review.pdf) + +## Optional links for today + + + +## Acknowledgements + +Slides for {{ COURSE_CODE }} were developed and created by [Dr. Cinda Heeren](https://www.cs.ubc.ca/people/cinda-heeren). The current iteration of the course resulted in minor adaptations and updates, but by in large, full credit of these slides belongs to Dr. Cinda Heeren. \ No newline at end of file diff --git a/notes/week04/homework.md b/notes/week04/homework.md new file mode 100644 index 0000000..fbefa6a --- /dev/null +++ b/notes/week04/homework.md @@ -0,0 +1,11 @@ +# Homework + +````{card} + +This week the homework assignment is on Chapter 2, and is posted on Mastering physics. + +```{button-link} https://portal.mypearson.com +Mastering Physics + +``` +```` \ No newline at end of file diff --git a/notes/week04/lab.md b/notes/week04/lab.md new file mode 100644 index 0000000..75a2dce --- /dev/null +++ b/notes/week04/lab.md @@ -0,0 +1,13 @@ +# Lab + + +````{card} + +The lab information for this week is in the Physics 111 Lab canvas course... + +```{button-link} https://canvas.ubc.ca/courses/66799 +Physics 111 Lab Canvas +:type: url +:classes: btn-outline-primary btn-block stretched-link text-dark +``` +```` \ No newline at end of file diff --git a/notes/week04/learninglogs.md b/notes/week04/learninglogs.md new file mode 100644 index 0000000..3e53e9b --- /dev/null +++ b/notes/week04/learninglogs.md @@ -0,0 +1,52 @@ +# Learning Logs + +This week's learning log assignment will be posted on Canvas by Thursday. + +Here are the questions you will be asked to answer in the learning logs. + +## Task 1: Formula Sheet + +It is about that time in the course where the number of formulas you have to keep track of is getting large. To help you keep track of the concept and formulas, and to encourage you to reference your own notes during assessments, this week's learning log is about getting you set up with your own formula sheet.  + +I have created a template for you below, but you are NOT required to use it! If you already have your own formula sheet and it's working for you, please continue to use it. + +Keep in mind though, that an ideal formula sheet helps you quickly (i.e. at a glance) find the information you need AND help you remember what you need to do with it. I wish someone had told me that during my undergraduate career!  + +If you have other/better versions that you'd like to share, be my guest (on Piazza)! Though I suggest you not allow others to *edit* your file. Each person should have their own formula sheet. + +[You can access my template and make a copy for yourself here.](https://docs.google.com/document/d/1H9Vyln44eBsdy4SRx9NFQoIbfuIfmVCQDyr-dUKxPYM/copy) + +## Task 2: Renew your vows + +Each week, I am asking you to type out the integrity pledge, letter by letter, so you understand how important it is to me that you maintain your academic integrity as you go through this course. + + + +## Task 3: Well-being check + +One of my goals this year is to help you (as best I can) manage your stress and anxieties by "measuring it" on a weekly basis and intervening or making suggestions during our weekly class meeting. +This is an exciting time for all of you as many of you are starting your undergraduate studies. +With this new excitement, you may be feeling additional stress and anxiety as you learn to manage this new life with its drastic changes, that too in the middle of a pandemic. +In terms of providing support for you as an instructor I’d like for us to measure/rate your anxiety and stress levels - I understand that you may not know what level of stress and/or anxiety is appropriate at this level of your education so feel free to note that! + +Q1: On a scale of 1-10, rate your CURRENT level of anxiety and stress: + +Anxiety: 1-10 +Stress: 1-10 + +Q2: On a scale of 1-10, rate WHERE DO YOU THINK YOUR level of anxiety and stress SHOULD BE: + +Anxiety: 1-10 +Stress: 1-10 + +Q3: Is there anything else you would like to tell me? + +[Open Text] + +I’ll do what I can within my role as an instructor, in terms of workload and due dates. +Part of undergraduate life and healthy living is finding ways to manage your stress and anxiety in a manner that is effective for you - this will look different for each person! +If you want to explore additional resources, start with the ones listed at [UBCV Health and wellbeing](https://students.ubc.ca/health) and see if the tips there work for you! + +Finally, remember (from the course syllabus): as I'm sure you're aware, *there is a global pandemic* happening right now and we could all use some extra compassion and humanity. +If you're going through something that is affecting you (course or otherwise), you are always welcome to come and talk to me about it. +If I am not able to help you myself, then I can probably direct you to the right person or resource. \ No newline at end of file diff --git a/notes/week04/lecture.md b/notes/week04/lecture.md new file mode 100644 index 0000000..4a95491 --- /dev/null +++ b/notes/week04/lecture.md @@ -0,0 +1,15 @@ +# Lecture + +This week we will do go over some key clicker questions from Chapter 4 today. + +## Sli.do Polls + +You can go to [https://sli.do/physics111](https://app.sli.do/event/lk89xpvr/live/polls) in a new tab or use the embedded poll here: + + + +## Slides from Lecture + +Will be available here after the lecture. + + \ No newline at end of file diff --git a/notes/week04/readings.md b/notes/week04/readings.md new file mode 100644 index 0000000..45e6b98 --- /dev/null +++ b/notes/week04/readings.md @@ -0,0 +1,30 @@ +# Readings + +This week the readings assignments are listed below: + + + + + + + + + + + + + +Click the button below to be taken to the Pearson textbook to access the eText + + +````{card} + +If you have access to the eText, you can go to the eText from here + +```{button-link} https://portal.mypearson.com +Pearson eText +:type: url +:classes: btn-outline-warning btn-block stretched-link text-dark +``` +```` + diff --git a/notes/week04/test.md b/notes/week04/test.md new file mode 100644 index 0000000..184de91 --- /dev/null +++ b/notes/week04/test.md @@ -0,0 +1,11 @@ +# Bonus Test 01 + +````{card} + +This week you will have an opportunity to do Bonus Test 01 on Chapters 2 and 3. The Bonus Test will be available from Thursday at 6 PM to Saturday at 6 PM. + +```{button-link} https://canvas.ubc.ca/courses/63995 +Canvas Assignments + +``` +```` \ No newline at end of file diff --git a/notes/week04/videos.md b/notes/week04/videos.md new file mode 100644 index 0000000..057c818 --- /dev/null +++ b/notes/week04/videos.md @@ -0,0 +1,68 @@ +# Videos + +Below are the assigned videos for this week. +The videos are collapsible so once you're done with one, you can move to the next one. +In the sidebar on the right, you can use the checklists to keep track of what's done. + +````{margin} +```{admonition} Checklist of items +:class: tip sticky + + + + + + + + + +``` +```` + +## Required Videos + +Below are the assigned videos for this week. + +### Videos before Tuesday's class + +```{dropdown} 1. Knitting Functions + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + +```{dropdown} 2. Introduction to Pandas + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + +### Videos before Thursday's class + +```{dropdown} 3. Data, Internet, and Billboard 100 + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + +```{dropdown} 4. Beautiful Soup + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` \ No newline at end of file diff --git a/notes/week04/week04_summary.md b/notes/week04/week04_summary.md new file mode 100755 index 0000000..2a37cd5 --- /dev/null +++ b/notes/week04/week04_summary.md @@ -0,0 +1,5 @@ +(page_topic4)= +Week 4 Summary +======================= + +This week we will be continuing knitting and learning about Python classes and learning about Pandas. \ No newline at end of file diff --git a/notes/week05/class5A.md b/notes/week05/class5A.md new file mode 100644 index 0000000..02d1265 --- /dev/null +++ b/notes/week05/class5A.md @@ -0,0 +1,27 @@ +# Class Meeting 5A + +Below are the slides from today's class embedded. +Feel free to download them to keep them locally, or leave them archived here and just bookmark them. +We will leave the website open even after the course is over for a reasonable number of years. + +
+ +
+ +[Download the Slides from today](https://github.com/ubc-cs/cpsc203/raw/main/files/Lec09_WebAsData.pdf) + +## Optional links for today + +- [LOTS More on Pandas!]https://firas.moosvi.com/courses/data301/2022_WT2/notes/week05/Class5A/Class5A.html + + + +## Acknowledgements + +Slides for {{ COURSE_CODE }} were developed and created by [Dr. Cinda Heeren](https://www.cs.ubc.ca/people/cinda-heeren). The current iteration of the course resulted in minor adaptations and updates, but by in large, full credit of these slides belongs to Dr. Cinda Heeren. \ No newline at end of file diff --git a/notes/week05/class5B.md b/notes/week05/class5B.md new file mode 100644 index 0000000..27026e7 --- /dev/null +++ b/notes/week05/class5B.md @@ -0,0 +1,25 @@ +# Class Meeting 5B + +Below are the slides from today's class embedded. +Feel free to download them to keep them locally, or leave them archived here and just bookmark them. +We will leave the website open even after the course is over for a reasonable number of years. + +
+ +
+ +[Download the Slides from today](https://github.com/ubc-cs/cpsc203/raw/main/files/Lec10_Plotting_DataFrames.pdf) + +## Optional links for today + + + +## Acknowledgements + +Slides for {{ COURSE_CODE }} were developed and created by [Dr. Cinda Heeren](https://www.cs.ubc.ca/people/cinda-heeren). The current iteration of the course resulted in minor adaptations and updates, but by in large, full credit of these slides belongs to Dr. Cinda Heeren. \ No newline at end of file diff --git a/notes/week05/homework.md b/notes/week05/homework.md new file mode 100644 index 0000000..e4c2283 --- /dev/null +++ b/notes/week05/homework.md @@ -0,0 +1,11 @@ +# Homework + +````{card} + +This week the homework assignment is on Chapter 5, and is posted on Mastering physics. + +```{button-link} https://portal.mypearson.com +Mastering Physics + +``` +```` \ No newline at end of file diff --git a/notes/week05/lab.md b/notes/week05/lab.md new file mode 100644 index 0000000..75a2dce --- /dev/null +++ b/notes/week05/lab.md @@ -0,0 +1,13 @@ +# Lab + + +````{card} + +The lab information for this week is in the Physics 111 Lab canvas course... + +```{button-link} https://canvas.ubc.ca/courses/66799 +Physics 111 Lab Canvas +:type: url +:classes: btn-outline-primary btn-block stretched-link text-dark +``` +```` \ No newline at end of file diff --git a/notes/week05/learninglogs.md b/notes/week05/learninglogs.md new file mode 100644 index 0000000..3e53e9b --- /dev/null +++ b/notes/week05/learninglogs.md @@ -0,0 +1,52 @@ +# Learning Logs + +This week's learning log assignment will be posted on Canvas by Thursday. + +Here are the questions you will be asked to answer in the learning logs. + +## Task 1: Formula Sheet + +It is about that time in the course where the number of formulas you have to keep track of is getting large. To help you keep track of the concept and formulas, and to encourage you to reference your own notes during assessments, this week's learning log is about getting you set up with your own formula sheet.  + +I have created a template for you below, but you are NOT required to use it! If you already have your own formula sheet and it's working for you, please continue to use it. + +Keep in mind though, that an ideal formula sheet helps you quickly (i.e. at a glance) find the information you need AND help you remember what you need to do with it. I wish someone had told me that during my undergraduate career!  + +If you have other/better versions that you'd like to share, be my guest (on Piazza)! Though I suggest you not allow others to *edit* your file. Each person should have their own formula sheet. + +[You can access my template and make a copy for yourself here.](https://docs.google.com/document/d/1H9Vyln44eBsdy4SRx9NFQoIbfuIfmVCQDyr-dUKxPYM/copy) + +## Task 2: Renew your vows + +Each week, I am asking you to type out the integrity pledge, letter by letter, so you understand how important it is to me that you maintain your academic integrity as you go through this course. + + + +## Task 3: Well-being check + +One of my goals this year is to help you (as best I can) manage your stress and anxieties by "measuring it" on a weekly basis and intervening or making suggestions during our weekly class meeting. +This is an exciting time for all of you as many of you are starting your undergraduate studies. +With this new excitement, you may be feeling additional stress and anxiety as you learn to manage this new life with its drastic changes, that too in the middle of a pandemic. +In terms of providing support for you as an instructor I’d like for us to measure/rate your anxiety and stress levels - I understand that you may not know what level of stress and/or anxiety is appropriate at this level of your education so feel free to note that! + +Q1: On a scale of 1-10, rate your CURRENT level of anxiety and stress: + +Anxiety: 1-10 +Stress: 1-10 + +Q2: On a scale of 1-10, rate WHERE DO YOU THINK YOUR level of anxiety and stress SHOULD BE: + +Anxiety: 1-10 +Stress: 1-10 + +Q3: Is there anything else you would like to tell me? + +[Open Text] + +I’ll do what I can within my role as an instructor, in terms of workload and due dates. +Part of undergraduate life and healthy living is finding ways to manage your stress and anxiety in a manner that is effective for you - this will look different for each person! +If you want to explore additional resources, start with the ones listed at [UBCV Health and wellbeing](https://students.ubc.ca/health) and see if the tips there work for you! + +Finally, remember (from the course syllabus): as I'm sure you're aware, *there is a global pandemic* happening right now and we could all use some extra compassion and humanity. +If you're going through something that is affecting you (course or otherwise), you are always welcome to come and talk to me about it. +If I am not able to help you myself, then I can probably direct you to the right person or resource. \ No newline at end of file diff --git a/notes/week05/lecture.md b/notes/week05/lecture.md new file mode 100644 index 0000000..7e07ceb --- /dev/null +++ b/notes/week05/lecture.md @@ -0,0 +1,15 @@ +# Lecture + +This week we will do go over some key clicker questions from Chapter 5 today. + +## Sli.do Polls + +You can go to [https://sli.do/physics111](https://app.sli.do/event/lk89xpvr/live/polls) in a new tab or use the embedded poll here: + + + +## Slides from Lecture + +Slides are available now, questions with answers will be available here after the lecture. + + \ No newline at end of file diff --git a/notes/week05/readings.md b/notes/week05/readings.md new file mode 100644 index 0000000..5c03713 --- /dev/null +++ b/notes/week05/readings.md @@ -0,0 +1,32 @@ +# Readings + +This week the readings assignments are listed below: + + + + + + + + + + + + + + + +Click the button below to be taken to the Pearson textbook to access the eText + + +````{card} + +If you have access to the eText, you can go to the eText from here + +```{button-link} https://portal.mypearson.com +Pearson eText +:type: url +:classes: btn-outline-warning btn-block stretched-link text-dark +``` +```` + diff --git a/notes/week05/test.md b/notes/week05/test.md new file mode 100644 index 0000000..5004cbc --- /dev/null +++ b/notes/week05/test.md @@ -0,0 +1,11 @@ +# Test + +````{card} + +This week will be Test 2, which will be on the contents of Chapter 4 and 5. + +```{button-link} https://canvas.ubc.ca +Canvas + +``` +```` \ No newline at end of file diff --git a/notes/week05/videos.md b/notes/week05/videos.md new file mode 100644 index 0000000..4abea32 --- /dev/null +++ b/notes/week05/videos.md @@ -0,0 +1,131 @@ +# Videos + +Below are the assigned videos for this week. +The videos are collapsible so once you're done with one, you can move to the next one. +In the sidebar on the right, you can use the checklists to keep track of what's done. + +````{margin} +```{admonition} Checklist of items +:class: tip sticky + + + + + + + +``` +```` + +## Required Videos + +Below are the assigned videos for this week. + +### Videos before Tuesday's class + +```{dropdown} 1. Data, Internet, and Billboard 100 + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + +```{dropdown} 2. Beautiful Soup + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` +### Videos before Thursday's class + +```{dropdown} 3. Dataframe Filtering + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + +```{dropdown} 4. Pandas and Dates + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + +```{dropdown} 5. Plotting with Pandas + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + +## Optional Videos + +```{dropdown} Pandas in Data Science Tutorial + :class-container: sd-shadow-lg + :color: primary + +Some of you have asked me for advanced Pandas tutorials for your own side-projects and other courses. +Though much of this content is beyond the scope of this course, here is a nice video that I assign to students in one of my other data science courses that might be useful for you. + +Here is an outline of the timestamps of this video (clickable links in the [YouTube Video description](https://www.youtube.com/watch?v=vmEHCJofslg&feature=emb_title)) + +- 0:00 - Why Pandas? +- 1:46 - Installing Pandas +- 2:03 - Getting the data used in this video +- 3:50 - Loading the data into Pandas (CSVs, Excel, TXTs, etc.) +- 8:49 - Reading Data (Getting Rows, Columns, Cells, Headers, etc.) +- 13:10 - Iterate through each Row +- 14:11 - Getting rows based on a specific condition +- 15:47 - High Level description of your data (min, max, mean, std dev, etc.) +- 16:24 - Sorting Values (Alphabetically, Numerically) +- 18:19 - Making Changes to the DataFrame +- 18:56 - Adding a column +- 21:22 - Deleting a column +- 22:14 - Summing Multiple Columns to Create new Column. +- 24:14 - Rearranging columns +- 28:06 - Saving our Data (CSV, Excel, TXT, etc.) +- 31:47 - Filtering Data (based on multiple conditions) +- 35:40 - Reset Index +- 37:41 - Regex Filtering (filter based on textual patterns) +- 43:08 - Conditional Changes +- 47:57 - Aggregate Statistics using Groupby (Sum, Mean, Counting) +- 54:53 - Working with large amounts of data (setting chunksize) + +You can download the [`pokemon.csv` dataset here](https://github.com/firasm/bits/raw/master/pokemon.csv) and [this notebook here](https://github.com/ubco-cmps/data301_course/raw/main/notes/week05/week05_pokemon.ipynb). + +
+ +
+``` + + +```{dropdown} 5. Seaborn + :class-container: sd-shadow-lg + :color: primary + +You can see the associated [Jupyter Notebook here](https://firas.moosvi.com/courses/data301/2022_WT2/notes/week06/Class6B/Class6B.html) + +
+ +
+``` \ No newline at end of file diff --git a/notes/week05/week05_summary.md b/notes/week05/week05_summary.md new file mode 100755 index 0000000..82de899 --- /dev/null +++ b/notes/week05/week05_summary.md @@ -0,0 +1,5 @@ +(page_topic5)= +Week 5 Summary +======================= + +This week we will start working with some data, using the BeautifulSoup, and parsing data from the internet! \ No newline at end of file diff --git a/notes/week06/Class8C/Class8C.ipynb b/notes/week06/Class8C/Class8C.ipynb new file mode 100644 index 0000000..26eb2b5 --- /dev/null +++ b/notes/week06/Class8C/Class8C.ipynb @@ -0,0 +1,509 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "slideshow": { + "slide_type": "skip" + }, + "tags": [ + "remove-cell" + ] + }, + "outputs": [ + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from IPython.display import IFrame\n", + "from IPython.display import Markdown\n", + "\n", + "# Additional styling ; should be moved into helpers\n", + "from IPython.display import display, HTML\n", + "\n", + "HTML(\"\".format(open(\"rise.css\").read()))" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "source": [ + "# Class 8C. Version Control with Git\n", + "\n", + "" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "source": [ + "## Lecture Outline" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "source": [ + "**1. Announcements (2 mins)**" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**2.Version Control with git? (3 mins)**" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**3. The GitHub flow (5 mins)**" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**4. Introduction to Branches and Pull Requests (10 mins)**" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**5. Guided Activity: Create a Branch, submit a Pull Request (25 mins)**" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "source": [ + "## Request for Volunteers !\n", + "\n", + "- You don't need to have any prior experience, nor do you have to be a computer pro.\n", + "- Probably will just ask you to share your screen and follow directions.\n", + "- I'll walk you through what you have to type and click and hopefully it's illustrative what needs to be done.\n", + "- You don't need to be a computer or git expert!\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "source": [ + "## 2. Version Control with Git" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "subslide" + } + }, + "source": [ + "### Why Git?\n", + "\n", + "" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "subslide" + } + }, + "source": [ + "## What is Git?\n", + "\n", + "\n", + "\n", + "Image Source: [Noble Desktop](https://www.nobledesktop.com/blog/what-is-git-and-why-should-you-use-it)." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "source": [ + "## Revisiting Learn Git Branching\n", + "\n", + "" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "source": [ + "## The GitHub Flow" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "slideshow": { + "slide_type": "fragment" + }, + "tags": [ + "hide-input" + ] + }, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "IFrame(\n", + " \"https://enterprise.github.com/downloads/en/github-flow-cheatsheet.pdf\",\n", + " width=1200,\n", + " height=800,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "source": [ + "## GitHub Guides\n", + "\n", + "See this link for lots more about using GitHub: https://github.com/git-guides" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Guided Activity: Create and resolve a merge conflict\n", + "\n", + "1. Message your group mates and get in touch with them\n", + "\n", + "2. ONE PERSON IN EACH ROOM, will fork this repository onto your own GitHub account\n", + "\n", + "3. Clone that fork onto your computer\n", + "\n", + "4. Add your teammates to the repository\n", + "\n", + "5. Teammates clone onto computer\n", + "\n", + "6. Try to create and resolve a merge conflict." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Lecture Outline" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**1. Announcements and Recap (5 mins)**" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "source": [ + "## Part 1. Announcements (5 mins)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "source": [ + "## Part 2. Introduction to Branches and Pull Requests (20 mins)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "source": [ + "### Create and switch to a new branch\n", + "\n", + "To checkout a new branch that **doesn't already exist**, use:\n", + "\n", + "```\n", + "git switch -c new_branch_name\n", + "```" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "source": [ + "### Switch to an existing branch\n", + "\n", + "To switch to a new branch that **already exists**, use:\n", + "\n", + "```\n", + "git switch branch_name\n", + "```" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "source": [ + "## Part 3. Guided Activity: Create a Branch, submit a Pull Request (20 mins)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "source": [ + "**- Important! Use your Group Project repo**\n", + "\n", + "Partner 1: \"Contributor 1\"\n", + "\n", + "Partner 2: \"Contributor 2\"\n", + "\n", + "Partner 3: Contributor 3\"\n", + "\n", + "- Partner 1 Creates and switches to a new branch:\n", + "\t- git switch -c newchange1\n", + "\n", + "- Partner 2 Creates and switches to a new branch:\n", + "\t- git switch -c newchange2\n", + "\n", + "- Partner 3 Creates and switches to a new branch:\n", + "\t- git switch -c newchange3\n", + " \n", + "- All partners make sure the branch is switched:\n", + "\t- git status\n", + "\n", + "- Partner 2 creates a new md file:\n", + "\t- code newfile.md\n", + "\t- Write a bunch of stuff\n", + "\t- Save\n", + "\t- git add .\n", + "\t- git commit -m \"new change\"\n", + "\t- git push\n", + "\n", + "- Partner 2 goes to the Github.com repo,\n", + "\t- Click \"Compare and Pull Request\"\n", + "\t- Request a review from Partner 1 and Partner 3\n", + "\t- Submit Pull Request\n", + " \n", + "- Partner 3 does the same thing as above" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "source": [ + "### Tips\n", + "Here are some command sequences that might be useful:\n", + "\n", + "```\n", + "- git switch -c 'person1'\n", + "- git switch -c 'person2'\n", + "- edit the file\n", + "- add, commit, push\n", + "- deal with the Pull Request(PR) on GitHub\n", + "```" + ] + } + ], + "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.10.2" + }, + "vscode": { + "interpreter": { + "hash": "4a3006030bc8f073e17f416a7c98291111bc2dc23e3286a5e86c679c75d3e5ba" + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/notes/week06/Class8C/rise.css b/notes/week06/Class8C/rise.css new file mode 100644 index 0000000..c3a7dfb --- /dev/null +++ b/notes/week06/Class8C/rise.css @@ -0,0 +1,80 @@ +/* ---------- markdown cells + */ +body.rise-enabled div.inner_cell>div.text_cell_render.rendered_html { + font-size: 120%; +} + + +/* ---------- code blocks inside markdown + i.e. within ``` lines, or 4-space indented + */ +div.inner_cell>div.text_cell_render.rendered_html>pre { + margin: 0px; +} + +/* ----------- code to remove space above markdown headers + */ +div.inner_cell>div.text_cell_render.rendered_html h1 { + margin-top: 0px; +} +div.inner_cell>div.text_cell_render.rendered_html h2 { + margin-top: 0px; +} +div.inner_cell>div.text_cell_render.rendered_html h3 { + margin-top: 0px; +} +div.inner_cell>div.text_cell_render.rendered_html h4 { + margin-top: 0px; +} + +div.inner_cell>div.text_cell_render.rendered_html>pre>code { + font-size: 70%; +} + +/* ---------- tables (from SO) + */ +.rendered_html table, .rendered_html th, .rendered_html tr, .rendered_html td { + font-size: 120%; +} + +/* ---------- Left part of code cells + from this SO answer: https://stackoverflow.com/a/47263575; + /* Narrow the prompts */ +div.prompt_container { + min-width: 5ex; +} +/* Hide prompts altogether for non-code cells */ +.cell:not(.code_cell) .prompt { + display: none; +} +/* ---------- Width of cells + */ +.container { + width:95% !important; +} + + +/* ---------- Vertical Whitespace + */ +.vspace { + margin-top:50px; +} +/* +div.cell.code_cell.rendered.selected, { + border-width:10px; + border-style:solid; + border-color:red; +} */ + + +/* Removes the border of cells */ + +div.cell { + border-width:0px; +} + +/* Increases the thickness of the blue and green (whether or not the cell is selected */ + +div.cell.selected:before; .edit_mode div.cell.selected:before { + width: 20px; +} diff --git a/notes/week06/class6A.md b/notes/week06/class6A.md new file mode 100644 index 0000000..316727d --- /dev/null +++ b/notes/week06/class6A.md @@ -0,0 +1,92 @@ +# Class Meeting 6A + +Below are the slides from today's class embedded. +Feel free to download them to keep them locally, or leave them archived here and just bookmark them. +We will leave the website open even after the course is over for a reasonable number of years. + +Today in class we will be doing a few demos of practical uses of git and version control. +For a good experience, you should come to class with your group mates, and sit close together. + +
+ +
+ +[Download the Slides from today](https://github.com/ubc-cs/cpsc203/raw/main/files/Lec11_Git_VersionControl.pdf) + + +## Version Control with Git + + + +- Why git? (3 mins) +- The GitHub flow (5 mins) +- Introduction to Branches and Pull Requests (10 mins) +- Guided Activity 1: Intro to Git and GitHub (25 mins) +- Guided Activity 2: Code Reviews (10 mins) +- Git Summary and Review (15 mins) + +### Why Git + + + +### What is Git? + + + +Image Source: [Noble Desktop](https://www.nobledesktop.com/blog/what-is-git-and-why-should-you-use-it). + +## Learn Git Branching + + + +## Request for Volunteers ! + +- You don't need to have any prior experience, nor do you have to be a computer pro. +- Probably will just ask you to share your screen and follow directions. +- I'll walk you through what you have to type and click and hopefully it's illustrative what needs to be done. +- You don't need to be a computer or git expert! + + +## Guided Activity 1: Intro to Git and GitHub + +You will need to get into a group of 3 for this activity, and it would be best if you all sat together. + +- Contributor 1 +- Contributor 2 +- Contributor 3 + +### Tasks: + +- Get into groups of 3 +- Accept a [**group** GitHub Classroom assignment](https://classroom.github.com/a/-GA1rFkW). +- Clone the repo locally using the Terminal. +- Open the repo in VS Code. +- Contributor 1,2,3 all independently make changes to fix their functions in VS Code +- Contributor 1,2,3 all commit to their repos BUT DO NOT PUSH! + +## Guided Activity 2: Code Reviews + +We'll now do a demo on how to submit a Pull Request, and do a code review. + + +## Useful Git Commands + +Here are some command sequences that might be useful: + +- `git status` +- `git clone ...` +- `git add .` or `git add -A` +- `git commit -m` +- `git switch -c 'person1'` +- `git switch -c 'person2'` +- `git add`, `git commit`, `git push` + +## Important links for today: + +- [GitHub Guide](https://github.com/git-guides) +- [Git Cheatsheet](https://enterprise.github.com/downloads/en/github-flow-cheatsheet.pdf) +- [LearnGitBranching](https://https://learngitbranching.js.org) + +## Acknowledgements + +Slides for {{ COURSE_CODE }} were developed and created by [Dr. Cinda Heeren](https://www.cs.ubc.ca/people/cinda-heeren). The current iteration of the course resulted in minor adaptations and updates, but by in large, full credit of these slides belongs to Dr. Cinda Heeren. \ No newline at end of file diff --git a/notes/week06/class6B.md b/notes/week06/class6B.md new file mode 100644 index 0000000..9e7c53e --- /dev/null +++ b/notes/week06/class6B.md @@ -0,0 +1,17 @@ +# Class Meeting 6B + +There is no class today - take some time to reflect on the content for this week, do your practice, and take the time to finish up Lab 5 (it's slightly longer this week). + +## Optional links for today + + + +## Acknowledgements + +Slides for {{ COURSE_CODE }} were developed and created by [Dr. Cinda Heeren](https://www.cs.ubc.ca/people/cinda-heeren). The current iteration of the course resulted in minor adaptations and updates, but by in large, full credit of these slides belongs to Dr. Cinda Heeren. \ No newline at end of file diff --git a/notes/week06/images/git.jpeg b/notes/week06/images/git.jpeg new file mode 100644 index 0000000..5d2cda0 Binary files /dev/null and b/notes/week06/images/git.jpeg differ diff --git a/notes/week06/images/git_model_googledoc.png b/notes/week06/images/git_model_googledoc.png new file mode 100644 index 0000000..e377bc0 Binary files /dev/null and b/notes/week06/images/git_model_googledoc.png differ diff --git a/notes/week06/images/learn_git_branching.png b/notes/week06/images/learn_git_branching.png new file mode 100644 index 0000000..25fb327 Binary files /dev/null and b/notes/week06/images/learn_git_branching.png differ diff --git a/notes/week06/videos.md b/notes/week06/videos.md new file mode 100644 index 0000000..d1e6edb --- /dev/null +++ b/notes/week06/videos.md @@ -0,0 +1,78 @@ +# Videos + +Below are the assigned videos for this week. +The videos are collapsible so once you're done with one, you can move to the next one. +In the sidebar on the right, you can use the checklists to keep track of what's done. + +````{margin} +```{admonition} Checklist of items +:class: tip sticky + + + + + + + + + + +``` +```` +## Required Videos + +```{attention} +To get the most benefit from class on Tuesday, ou will definitely need to have watched these videos BEFORE class on Tuesday! +``` + +```{dropdown} Why Use Git? + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + +```{dropdown} How Git Works + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + +```{dropdown} Creating a repository + :class-container: sd-shadow-lg + :color: primary + :open: + + Note: It is important you know how to create a repository for your own personal projects. However in this course, you will always get a "GitHub Classroom link" that will create a repository with some starter code. + +
+ +
+``` + +```{dropdown} Staging Files + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + +```{dropdown} Making Commits + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` \ No newline at end of file diff --git a/notes/week06/week06_summary.md b/notes/week06/week06_summary.md new file mode 100755 index 0000000..ac55004 --- /dev/null +++ b/notes/week06/week06_summary.md @@ -0,0 +1,5 @@ +(page_topic6)= +Week 6 Summary +======================= + +This week we will start introducing a new tool in our course, Git and GitHub! \ No newline at end of file diff --git a/notes/week07/homework.md b/notes/week07/homework.md new file mode 100644 index 0000000..d487dc7 --- /dev/null +++ b/notes/week07/homework.md @@ -0,0 +1,11 @@ +# Homework + +````{card} + +This week the homework assignment is on Chapter 6, and is posted on Mastering physics. + +```{button-link} https://portal.mypearson.com +Mastering Physics + +``` +```` \ No newline at end of file diff --git a/notes/week07/lab.md b/notes/week07/lab.md new file mode 100644 index 0000000..75a2dce --- /dev/null +++ b/notes/week07/lab.md @@ -0,0 +1,13 @@ +# Lab + + +````{card} + +The lab information for this week is in the Physics 111 Lab canvas course... + +```{button-link} https://canvas.ubc.ca/courses/66799 +Physics 111 Lab Canvas +:type: url +:classes: btn-outline-primary btn-block stretched-link text-dark +``` +```` \ No newline at end of file diff --git a/notes/week07/learninglogs.md b/notes/week07/learninglogs.md new file mode 100644 index 0000000..3e53e9b --- /dev/null +++ b/notes/week07/learninglogs.md @@ -0,0 +1,52 @@ +# Learning Logs + +This week's learning log assignment will be posted on Canvas by Thursday. + +Here are the questions you will be asked to answer in the learning logs. + +## Task 1: Formula Sheet + +It is about that time in the course where the number of formulas you have to keep track of is getting large. To help you keep track of the concept and formulas, and to encourage you to reference your own notes during assessments, this week's learning log is about getting you set up with your own formula sheet.  + +I have created a template for you below, but you are NOT required to use it! If you already have your own formula sheet and it's working for you, please continue to use it. + +Keep in mind though, that an ideal formula sheet helps you quickly (i.e. at a glance) find the information you need AND help you remember what you need to do with it. I wish someone had told me that during my undergraduate career!  + +If you have other/better versions that you'd like to share, be my guest (on Piazza)! Though I suggest you not allow others to *edit* your file. Each person should have their own formula sheet. + +[You can access my template and make a copy for yourself here.](https://docs.google.com/document/d/1H9Vyln44eBsdy4SRx9NFQoIbfuIfmVCQDyr-dUKxPYM/copy) + +## Task 2: Renew your vows + +Each week, I am asking you to type out the integrity pledge, letter by letter, so you understand how important it is to me that you maintain your academic integrity as you go through this course. + + + +## Task 3: Well-being check + +One of my goals this year is to help you (as best I can) manage your stress and anxieties by "measuring it" on a weekly basis and intervening or making suggestions during our weekly class meeting. +This is an exciting time for all of you as many of you are starting your undergraduate studies. +With this new excitement, you may be feeling additional stress and anxiety as you learn to manage this new life with its drastic changes, that too in the middle of a pandemic. +In terms of providing support for you as an instructor I’d like for us to measure/rate your anxiety and stress levels - I understand that you may not know what level of stress and/or anxiety is appropriate at this level of your education so feel free to note that! + +Q1: On a scale of 1-10, rate your CURRENT level of anxiety and stress: + +Anxiety: 1-10 +Stress: 1-10 + +Q2: On a scale of 1-10, rate WHERE DO YOU THINK YOUR level of anxiety and stress SHOULD BE: + +Anxiety: 1-10 +Stress: 1-10 + +Q3: Is there anything else you would like to tell me? + +[Open Text] + +I’ll do what I can within my role as an instructor, in terms of workload and due dates. +Part of undergraduate life and healthy living is finding ways to manage your stress and anxiety in a manner that is effective for you - this will look different for each person! +If you want to explore additional resources, start with the ones listed at [UBCV Health and wellbeing](https://students.ubc.ca/health) and see if the tips there work for you! + +Finally, remember (from the course syllabus): as I'm sure you're aware, *there is a global pandemic* happening right now and we could all use some extra compassion and humanity. +If you're going through something that is affecting you (course or otherwise), you are always welcome to come and talk to me about it. +If I am not able to help you myself, then I can probably direct you to the right person or resource. \ No newline at end of file diff --git a/notes/week07/lecture.md b/notes/week07/lecture.md new file mode 100644 index 0000000..423bcc8 --- /dev/null +++ b/notes/week07/lecture.md @@ -0,0 +1,15 @@ +# Lecture + +This week we will do go over some key clicker questions from Chapter 6. + +## Sli.do Polls + +You can go to [https://sli.do/physics111](https://app.sli.do/event/lk89xpvr/live/polls) in a new tab or use the embedded poll here: + + + +## Slides from Lecture + +Slides are available now, questions with answers will be available here after the lecture. + + \ No newline at end of file diff --git a/notes/week07/readings.md b/notes/week07/readings.md new file mode 100644 index 0000000..f1f4cd8 --- /dev/null +++ b/notes/week07/readings.md @@ -0,0 +1,30 @@ +# Readings + +This week the readings assignments are listed below: + + + + + + + + + + + + + +Click the button below to be taken to the Pearson textbook to access the eText + + +````{card} + +If you have access to the eText, you can go to the eText from here + +```{button-link} https://portal.mypearson.com +Pearson eText +:type: url +:classes: btn-outline-warning btn-block stretched-link text-dark +``` +```` + diff --git a/notes/week07/test.md b/notes/week07/test.md new file mode 100644 index 0000000..66ebc07 --- /dev/null +++ b/notes/week07/test.md @@ -0,0 +1,11 @@ +# Test + +````{card} + +This week is Bonus Test 2, and it will mostly be on the contents of Chapter 4 and 5. + +```{button-link} https://canvas.ubc.ca +Canvas + +``` +```` \ No newline at end of file diff --git a/notes/week07/videos.md b/notes/week07/videos.md new file mode 100644 index 0000000..acb2989 --- /dev/null +++ b/notes/week07/videos.md @@ -0,0 +1,224 @@ +# Videos + +Below are the assigned videos for this week. +The videos are collapsible so once you're done with one, you can move to the next one. +In the sidebar on the right, you can use the checklists to keep track of what's done. + +````{margin} +```{admonition} Checklist of items +:class: tip + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` +```` + +## Required Videos + +```{dropdown} 1. Introduction to Equilibrium + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0119_lecture_notes_-_introduction_to_equilibrium.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/equilibrium.html) +``` + +```{dropdown} 2. Breaking the Force of Gravity into its Components on an Incline + :class-container: sd-shadow-lg + :color: primary + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0132_lecture_notes_-_breaking_the_force_of_gravity_into_its_components_on_an_incline.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/incline-components.html) +``` + +```{dropdown} 3. Do You Feel Your Weight? A lesson on Apparent Weight + :class-container: sd-shadow-lg + :color: primary + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0165_lecture_notes_-_an_introductory_kinetic_friction_on_an_incline_problem_1.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/apparent-weight.html) +``` + +```{dropdown} 4. Introduction to Static and Kinetic Friction by Bobby + :class-container: sd-shadow-lg + :color: primary + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0124_lecture_notes_-_introduction_to_static_and_kinetic_friction_by_bobby.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/friction-intro.html) +``` + +```{dropdown} 5. Introduction to the Coefficient of Friction + :class-container: sd-shadow-lg + :color: primary + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0125_lecture_notes_-_introduction_to_the_coefficient_of_friction.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/mu-intro.html) +``` + +```{dropdown} 6. Understanding the Force of Friction Equation + :class-container: sd-shadow-lg + :color: primary + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0126_lecture_notes_-_understanding_the_force_of_friction_equation.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/friction-equation.html) +``` + +```{dropdown} 7. Introductory Static Friction on an Incline Problem + :class-container: sd-shadow-lg + :color: primary + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0164_lecture_notes_-_an_introductory_static_friction_on_an_incline_problem.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/static-friction-incline.html) +``` + +```{dropdown} 8. Introductory Kinetic Friction on an Incline Problem + :class-container: sd-shadow-lg + :color: primary + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0165_lecture_notes_-_an_introductory_kinetic_friction_on_an_incline_problem.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/kinetic-friction-incline.html) +``` +```{dropdown} 9. Do Your Feet Affect How Far You Slide on a Water Slide? + :class-container: sd-shadow-lg + :color: primary + +
+ +
+- [Direct link to Mr. P's page](https://www.flippingphysics.com/water-slide.html) +``` + +```{dropdown} 10. Deriving the Equation for Terminal Velocity + :class-container: sd-shadow-lg + :color: primary + +
+ +
+``` + +## Optional Videos + +The videos below are relevant to the subject material, but are not required for Physics 111. + +```{dropdown} 11. Physics "Magic Trick" on an Incline + :class-container: sd-shadow-lg + :color: primary + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0133_lecture_notes_-_physics_magic_trick_on_an_incline.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/magic-trick.html) + +``` +```{dropdown} 12. Does the Book Move? An Introductory Friction Problem + :class-container: sd-shadow-lg + :color: primary + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0128_lecture_notes_-_does_the_book_move-_an_introductory_friction_problem.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/friction-problem.html) + +``` +```{dropdown} 13. Do Anti-lock Brakes use Static or Kinetic Friction? by Billy + :class-container: sd-shadow-lg + :color: primary + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0129_lecture_notes_-_do_anti-lock_brakes_use_static_or_kinetic_friction_by_billy.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/abs-brakes.html) + +``` +```{dropdown} 14. A Friction Review Problem - The Original Billy Bobby and Bo + :class-container: sd-shadow-lg + :color: primary + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/04-04_in-class_lecture_notes_-_a_friction_review_problem_-_the_original_billy_bobby_and_bo.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/friction-review-problem.html) + +``` +```{dropdown} 15. Determining the Static Coefficient of Friction between Tires and Snow + :class-container: sd-shadow-lg + :color: primary + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0131_lecture_notes_-_determining_the_static_coefficient_of_friction_between_tires_and_snow.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/tire-friction.html) + +``` diff --git a/notes/week07/week06_summary.md b/notes/week07/week06_summary.md new file mode 100755 index 0000000..483489e --- /dev/null +++ b/notes/week07/week06_summary.md @@ -0,0 +1,22 @@ +(page_topic6)= +Week 6 Summary +======================= + +This week there is no new content (except for your lab) in this course. +This week, you'll have an opportunity to catch your breath and catch up on anything from the last few weeks that you didn't have time to grasp or go through. +This may include test questions, missed homework questions, videos that you didn't watch, readings you didn't do, or anything else. +Though you don't *have to* use this break for Physics work, I encourage you to make sure you are actually caught up before re-purposing that time for other courses. +That being said, I understand it's midterm season so I'm sure you'll have plenty of things to fill your time with. + + +```{dropdown} Portal + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+ +[Link to the game](https://store.steampowered.com/app/400/Portal) +``` \ No newline at end of file diff --git a/notes/week07/week07_summary.md b/notes/week07/week07_summary.md new file mode 100755 index 0000000..fdca5ca --- /dev/null +++ b/notes/week07/week07_summary.md @@ -0,0 +1,22 @@ +(page_topic7)= +Week 7 Summary +======================= + +This week there is no new content in this course - it's Reading week! +This week, you'll have an opportunity to catch your breath and catch up on anything from the last few weeks that you didn't have time to grasp or go through. +This may include test questions, missed POTW questions, videos that you didn't watch, activities you didn't finish, or anything else left over. +Though you don't *have to* use this break for CPSC 203, I encourage you to make sure you are actually caught up before re-purposing that time for other courses. + +Here's a fun video from a game I enjoyed playing a lot! + +```{dropdown} Portal + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+ +[Link to the game](https://store.steampowered.com/app/400/Portal) +``` \ No newline at end of file diff --git a/notes/week08/class8A.md b/notes/week08/class8A.md new file mode 100644 index 0000000..6b07d73 --- /dev/null +++ b/notes/week08/class8A.md @@ -0,0 +1,47 @@ +# Class Meeting 8A + +Slides will be released before class (sorry!). + +
+ +
+ +[Download the Slides from today](https://github.com/ubc-cs/cpsc203/raw/main/files/Lec12_DataStructures.pdf) + +## Important links for today: + +- [Guide to python data structures](https://www.geeksforgeeks.org/python-data-structures/) +- [Deque](https://www.geeksforgeeks.org/deque-in-python/) + + + +## Logistics + +1. Jupyter Lab + +For class today, you will need to install JupyterLab because we'll be using an `.ipynb` file to use the `%%timeit` cell-magic. +You can do this by running the following command in the Terminal: + +``` +conda install -c conda-forge jupyterlab +``` + +You can then run `jupyter lab` in the Terminal to launch a JupyterLab instance. + +2. Clone the Class Activity Repository + +You will first need to "accept" the GitHub Classroom assignment to get a copy of the starter code. + +You can do that by [clicking here](https://classroom.github.com/a/o6D2NVBz). + +Then, clone the `classActivity0XY` repository by running the following line in your Terminal: + +``` +git clone +``` + +## Acknowledgements + +Slides for {{ COURSE_CODE }} were developed and created by [Dr. Cinda Heeren](https://www.cs.ubc.ca/people/cinda-heeren). The current iteration of the course resulted in minor adaptations and updates, but by in large, full credit of these slides belongs to Dr. Cinda Heeren. \ No newline at end of file diff --git a/notes/week08/class8B.md b/notes/week08/class8B.md new file mode 100644 index 0000000..eb9077a --- /dev/null +++ b/notes/week08/class8B.md @@ -0,0 +1,35 @@ +# Class Meeting 8B + +Slides will be released before class (sorry!). + +
+ +
+ +[Download the Slides from today](https://github.com/ubc-cs/cpsc203/raw/main/files/Lec13_Voronoi.pdf) + +## Important links for today: + +- [Deque](https://www.geeksforgeeks.org/deque-in-python/) + + + +## Logistics + +1. Clone the Class Activity Repository + +You will first need to "accept" the GitHub Classroom assignment to get a copy of the starter code. + +You can do that by [clicking here](https://classroom.github.com/a/ACntc8CV). + +Then, clone the `classActivity0XY` repository by running the following line in your Terminal: + +``` +git clone +``` + +## Acknowledgements + +Slides for {{ COURSE_CODE }} were developed and created by [Dr. Cinda Heeren](https://www.cs.ubc.ca/people/cinda-heeren). The current iteration of the course resulted in minor adaptations and updates, but by in large, full credit of these slides belongs to Dr. Cinda Heeren. \ No newline at end of file diff --git a/notes/week08/videos.md b/notes/week08/videos.md new file mode 100644 index 0000000..d88ae6a --- /dev/null +++ b/notes/week08/videos.md @@ -0,0 +1,93 @@ +# Videos + +Below are the assigned videos for this week. +The videos are collapsible so once you're done with one, you can move to the next one. +In the sidebar on the right, you can use the checklists to keep track of what's done. + +````{margin} +```{admonition} Checklist of items +:class: tip sticky + + + + + + + + + + + +``` +```` +## Required Videos + +### Tuesday's Class + + +```{dropdown} 1. What are Data Structures? + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + + +```{dropdown} 2. Introduction to Queues + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + + +### Thursday's class + +```{dropdown} 1. Motivating Voronoi Diagrams + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + +```{dropdown} 2. Computing Voronoi Diagrams + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + +```{dropdown} 3. Queues and Voronoi Diagrams + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + +### Optional Videos + +This will be a required video next week (Week 9). + +```{dropdown} 4. Pointilism + :class-container: sd-shadow-lg + :color: primary + +
+ +
+``` \ No newline at end of file diff --git a/notes/week08/week08_summary.md b/notes/week08/week08_summary.md new file mode 100755 index 0000000..e7e7e1a --- /dev/null +++ b/notes/week08/week08_summary.md @@ -0,0 +1,5 @@ +(page_topic8)= +Week 8 Summary +======================= + +This week we will talk about some new Data Structures and formalize a language for all the data structures we've seen (and will see)! \ No newline at end of file diff --git a/notes/week09/class9A.md b/notes/week09/class9A.md new file mode 100644 index 0000000..3082822 --- /dev/null +++ b/notes/week09/class9A.md @@ -0,0 +1,36 @@ +# Class Meeting 9A + +Today we will be wrapping up our Voronoi Art code and finishing it up. + +
+ +
+ +[Download the Slides from today](https://github.com/ubc-cs/cpsc203/raw/main/files/Lec14_Voronoi2_Graphs.pdf) + +## Important links for today: + +- [Deque](https://www.geeksforgeeks.org/deque-in-python/) +- [Math Pre-requisite Graph](https://ubcmath.github.io/coursemap/) + + + +## Logistics + +1. Clone the Class Activity Repository + +You will first need to "accept" the GitHub Classroom assignment to get a copy of the starter code. + +You can do that by [clicking here](https://classroom.github.com/a/9O9S8RgF). + +Then, clone the `classActivity0XY` repository by running the following line in your Terminal: + +``` +git clone +``` + +## Acknowledgements + +Slides for {{ COURSE_CODE }} were developed and created by [Dr. Cinda Heeren](https://www.cs.ubc.ca/people/cinda-heeren). The current iteration of the course resulted in minor adaptations and updates, but by in large, full credit of these slides belongs to Dr. Cinda Heeren. \ No newline at end of file diff --git a/notes/week09/class9B.md b/notes/week09/class9B.md new file mode 100644 index 0000000..23ff083 --- /dev/null +++ b/notes/week09/class9B.md @@ -0,0 +1,38 @@ +# Class Meeting 9B + +Today we will be continuing our discussion on Graphs + +
+ +
+ +[Download the Slides from today](https://github.com/ubc-cs/cpsc203/raw/main/files/Lec15_Graph_Exploration.pdf) + +## Important links for today: + +- [Graphs Tutorial](https://www.geeksforgeeks.org/introduction-to-graphs-data-structure-and-algorithm-tutorials/?ref=gcse) + + + +## Logistics + +Nothing to clone for today - I think! + + + +## Acknowledgements + +Slides for {{ COURSE_CODE }} were developed and created by [Dr. Cinda Heeren](https://www.cs.ubc.ca/people/cinda-heeren). The current iteration of the course resulted in minor adaptations and updates, but by in large, full credit of these slides belongs to Dr. Cinda Heeren. \ No newline at end of file diff --git a/notes/week09/videos.md b/notes/week09/videos.md new file mode 100644 index 0000000..f777f95 --- /dev/null +++ b/notes/week09/videos.md @@ -0,0 +1,85 @@ +# Videos + +Below are the assigned videos for this week. +The videos are collapsible so once you're done with one, you can move to the next one. +In the sidebar on the right, you can use the checklists to keep track of what's done. + + + + +## Required Videos + +### Tuesday's Class + +None! + + +### Thursday's class + +More videos coming soon... + +```{dropdown} 1. Directed Graphs + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + +```{dropdown} 2. Graph Exploration + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + + diff --git a/notes/week09/week09_summary.md b/notes/week09/week09_summary.md new file mode 100755 index 0000000..e360f1a --- /dev/null +++ b/notes/week09/week09_summary.md @@ -0,0 +1,5 @@ +(page_topic9)= +Week 9 Summary +======================= + +This week we will finish up with queues, and then move on to Graphs as a new data structure. \ No newline at end of file diff --git a/notes/week10/homework.md b/notes/week10/homework.md new file mode 100644 index 0000000..2a1da6e --- /dev/null +++ b/notes/week10/homework.md @@ -0,0 +1,11 @@ +# Homework + +````{card} + +This week the homework assignment is on Chapter 9, and is posted on Mastering physics. + +```{button-link} https://portal.mypearson.com +Mastering Physics + +``` +```` \ No newline at end of file diff --git a/notes/week10/lab.md b/notes/week10/lab.md new file mode 100644 index 0000000..75a2dce --- /dev/null +++ b/notes/week10/lab.md @@ -0,0 +1,13 @@ +# Lab + + +````{card} + +The lab information for this week is in the Physics 111 Lab canvas course... + +```{button-link} https://canvas.ubc.ca/courses/66799 +Physics 111 Lab Canvas +:type: url +:classes: btn-outline-primary btn-block stretched-link text-dark +``` +```` \ No newline at end of file diff --git a/notes/week10/learninglogs.md b/notes/week10/learninglogs.md new file mode 100644 index 0000000..3e53e9b --- /dev/null +++ b/notes/week10/learninglogs.md @@ -0,0 +1,52 @@ +# Learning Logs + +This week's learning log assignment will be posted on Canvas by Thursday. + +Here are the questions you will be asked to answer in the learning logs. + +## Task 1: Formula Sheet + +It is about that time in the course where the number of formulas you have to keep track of is getting large. To help you keep track of the concept and formulas, and to encourage you to reference your own notes during assessments, this week's learning log is about getting you set up with your own formula sheet.  + +I have created a template for you below, but you are NOT required to use it! If you already have your own formula sheet and it's working for you, please continue to use it. + +Keep in mind though, that an ideal formula sheet helps you quickly (i.e. at a glance) find the information you need AND help you remember what you need to do with it. I wish someone had told me that during my undergraduate career!  + +If you have other/better versions that you'd like to share, be my guest (on Piazza)! Though I suggest you not allow others to *edit* your file. Each person should have their own formula sheet. + +[You can access my template and make a copy for yourself here.](https://docs.google.com/document/d/1H9Vyln44eBsdy4SRx9NFQoIbfuIfmVCQDyr-dUKxPYM/copy) + +## Task 2: Renew your vows + +Each week, I am asking you to type out the integrity pledge, letter by letter, so you understand how important it is to me that you maintain your academic integrity as you go through this course. + + + +## Task 3: Well-being check + +One of my goals this year is to help you (as best I can) manage your stress and anxieties by "measuring it" on a weekly basis and intervening or making suggestions during our weekly class meeting. +This is an exciting time for all of you as many of you are starting your undergraduate studies. +With this new excitement, you may be feeling additional stress and anxiety as you learn to manage this new life with its drastic changes, that too in the middle of a pandemic. +In terms of providing support for you as an instructor I’d like for us to measure/rate your anxiety and stress levels - I understand that you may not know what level of stress and/or anxiety is appropriate at this level of your education so feel free to note that! + +Q1: On a scale of 1-10, rate your CURRENT level of anxiety and stress: + +Anxiety: 1-10 +Stress: 1-10 + +Q2: On a scale of 1-10, rate WHERE DO YOU THINK YOUR level of anxiety and stress SHOULD BE: + +Anxiety: 1-10 +Stress: 1-10 + +Q3: Is there anything else you would like to tell me? + +[Open Text] + +I’ll do what I can within my role as an instructor, in terms of workload and due dates. +Part of undergraduate life and healthy living is finding ways to manage your stress and anxiety in a manner that is effective for you - this will look different for each person! +If you want to explore additional resources, start with the ones listed at [UBCV Health and wellbeing](https://students.ubc.ca/health) and see if the tips there work for you! + +Finally, remember (from the course syllabus): as I'm sure you're aware, *there is a global pandemic* happening right now and we could all use some extra compassion and humanity. +If you're going through something that is affecting you (course or otherwise), you are always welcome to come and talk to me about it. +If I am not able to help you myself, then I can probably direct you to the right person or resource. \ No newline at end of file diff --git a/notes/week10/lecture.md b/notes/week10/lecture.md new file mode 100644 index 0000000..f1a9fd7 --- /dev/null +++ b/notes/week10/lecture.md @@ -0,0 +1,6 @@ +# Lecture + +This week the lecture is CANCELLED due to the Remembrance Day Holiday. + +There will be an OPTIONAL makeup class on Monday or Tuesday the following week. +It will be recorded. \ No newline at end of file diff --git a/notes/week10/readings.md b/notes/week10/readings.md new file mode 100644 index 0000000..6e7df5f --- /dev/null +++ b/notes/week10/readings.md @@ -0,0 +1,30 @@ +# Readings + +This week the readings assignments are listed below: + + + + + + + + + + + + + +Click the button below to be taken to the Pearson textbook to access the eText + + +````{card} + +If you have access to the eText, you can go to the eText from here + +```{button-link} https://portal.mypearson.com +Pearson eText +:type: url +:classes: btn-outline-warning btn-block stretched-link text-dark +``` +```` + diff --git a/notes/week10/test.md b/notes/week10/test.md new file mode 100644 index 0000000..9221b81 --- /dev/null +++ b/notes/week10/test.md @@ -0,0 +1,11 @@ +# Test + +````{card} + +This week is a Test, and it will mostly be on the contents of Chapter 8 and 9. + +```{button-link} https://canvas.ubc.ca +Canvas + +``` +```` \ No newline at end of file diff --git a/notes/week10/videos.md b/notes/week10/videos.md new file mode 100644 index 0000000..6c39556 --- /dev/null +++ b/notes/week10/videos.md @@ -0,0 +1,187 @@ +# Videos + +Below are the assigned videos for this week. +The videos are collapsible so once you're done with one, you can move to the next one. +In the sidebar on the right, you can use the checklists to keep track of what's done. + +````{margin} +```{admonition} Checklist of items +:class: tip + + + + + + + + + + + + + + + + + + + + + + + + +``` +```` + +## Content Summary from Crash Course Physics + +```{dropdown} Work, Energy, and Power + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + +## Required Videos + +```{dropdown} 1. Introduction to Work with Examples + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0134_lecture_notes_-_introduction_to_work_with_examples.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/work-intro.html) +``` + +```{dropdown} 2. Introductory Work Problem + :class-container: sd-shadow-lg + :color: primary + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0137_lecture_notes_-_introductory_work_problem.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/work-problem.html) +``` + +```{dropdown} 3. Introduction to Kinetic Energy with Example Problem + :class-container: sd-shadow-lg + :color: primary + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0138_lecture_notes_-_introduction_to_kinetic_energy_with_example_problem.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/intro-ke.html) +``` + +```{dropdown} 4. Introduction to the Integral or Anti-Derivative for use in Work from a Non-Constant Force + :class-container: sd-shadow-lg + :color: primary + +
+ +
+``` + +```{dropdown} 5. Defining Work with the Dot Product and a Review of the Dot Product - Constant Force + :class-container: sd-shadow-lg + :color: primary + +
+ +
+``` + +```{dropdown} 6. Hooke's Law Introduction - Force of a Spring + :class-container: sd-shadow-lg + :color: primary + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0248_lecture_notes_-_hookes_law_introduction_-_force_of_a_spring.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/hookes-law.html) +``` + +```{dropdown} 7. Determining the Spring Constant, k, with a Vertically Hanging Mass + :class-container: sd-shadow-lg + :color: primary + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0249_lecture_notes_-_determining_the_spring_constant_k_with_a_vertically_hanging_mass.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/vertical-spring-constant.html) +``` + +```{dropdown} 8. The Human Spine acts like a Compression Spring + :class-container: sd-shadow-lg + :color: primary + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0250_lecture_notes_-_the_human_spine_acts_like_a_compression_spring.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/horizontal-spring-constant.html) +``` + +```{dropdown} 9. Introduction to Mechanical Energy with Friction + :class-container: sd-shadow-lg + :color: primary + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0145_lecture_notes_-_introduction_to_mechanical_energy_with_friction.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/intro-wf.html) +``` + +```{dropdown} 10. Introductory Work due to Friction equals Change in Mechanical Energy Problem + :class-container: sd-shadow-lg + :color: primary + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0148_lecture_notes_-_introductory_work_due_to_friction_equals_change_in_mechanical_energy_problem.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/intro-wf-problem.html) +``` + +```{dropdown} 11. Introduction to Power + :class-container: sd-shadow-lg + :color: primary + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0162_lecture_notes_-_introduction_to_power.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/power.html) +``` + +```{dropdown} 12. Average and Instantaneous Power Example + :class-container: sd-shadow-lg + :color: primary + +
+ +
+ +- [Notes](https://www.flippingphysics.com/uploads/2/1/1/0/21103672/0163_lecture_notes_-_average_and_instantaneous_power_example.pdf) +- [Direct link to Mr. P's page](https://www.flippingphysics.com/power-example.html) +``` diff --git a/notes/week10/week10_summary.md b/notes/week10/week10_summary.md new file mode 100755 index 0000000..43cca4d --- /dev/null +++ b/notes/week10/week10_summary.md @@ -0,0 +1,23 @@ +(page_topic10)= +Week 10 Summary +======================= + +## List of things to do this week + +Below is a list of things you need to do this week, links to where you can do them, as well as roughly the order you should do it. +Note that these are just SUGGESTIONS and you are by no means required to them this way. +I have put the labs at the end, but if your lab section is earlier in the week, you may want to shift things around to accommodate that. + + + + + + + + + + + + + + \ No newline at end of file diff --git a/notes/week11/class11A.md b/notes/week11/class11A.md new file mode 100644 index 0000000..eebae29 --- /dev/null +++ b/notes/week11/class11A.md @@ -0,0 +1,36 @@ +# Class Meeting 11A + +Today we will be working on creating some music (and later linking it back to Graphs)! + +
+ +
+ +[Download the Slides from today](https://github.com/ubc-cs/cpsc203/raw/main/files/Lec16_MHall.pdf) + +## Important links for today: + +- [Markov Chains Demo](http://setosa.io/markov) +- [Markov Chains](https://brilliant.org/wiki/markov-chains/) + + + +## Logistics + +1. Clone the Class Activity Repository + +You will first need to "accept" the GitHub Classroom assignment to get a copy of the starter code. + +You can do that by [clicking here](https://classroom.github.com/a/ShgbwvAQ). + +Then, clone the `classActivity1XY` repository by running the following line in your Terminal: + +``` +git clone +``` + +## Acknowledgements + +Slides for {{ COURSE_CODE }} were developed and created by [Dr. Cinda Heeren](https://www.cs.ubc.ca/people/cinda-heeren). The current iteration of the course resulted in minor adaptations and updates, but by in large, full credit of these slides belongs to Dr. Cinda Heeren. \ No newline at end of file diff --git a/notes/week11/class11B.md b/notes/week11/class11B.md new file mode 100644 index 0000000..a4f00fa --- /dev/null +++ b/notes/week11/class11B.md @@ -0,0 +1,36 @@ +# Class Meeting 11B + +Today's class is cancelled so you have some time to get started on Project 2. +One of our TAs, Minh, has made a video to help you get started if you're stuck. + +```{dropdown} 1. Introduction to Project 2 + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + + +## Logistics + +Nothing to clone for today - I think! + + + +## Acknowledgements + +Slides for {{ COURSE_CODE }} were developed and created by [Dr. Cinda Heeren](https://www.cs.ubc.ca/people/cinda-heeren). The current iteration of the course resulted in minor adaptations and updates, but by in large, full credit of these slides belongs to Dr. Cinda Heeren. \ No newline at end of file diff --git a/notes/week11/videos.md b/notes/week11/videos.md new file mode 100644 index 0000000..f5a4e41 --- /dev/null +++ b/notes/week11/videos.md @@ -0,0 +1,85 @@ +# Videos + +Below are the assigned videos for this week. +The videos are collapsible so once you're done with one, you can move to the next one. +In the sidebar on the right, you can use the checklists to keep track of what's done. + + + +````{margin} +```{admonition} Checklist of items +:class: tip sticky + + + + + + +``` +```` + + +## Required Videos + +### Tuesday's Class + +```{dropdown} 1. Music Generation + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + +### Thursday's class + +```{dropdown} 1. Introduction to Project 2 + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + + + + diff --git a/notes/week11/week11_summary.md b/notes/week11/week11_summary.md new file mode 100755 index 0000000..cb9178f --- /dev/null +++ b/notes/week11/week11_summary.md @@ -0,0 +1,5 @@ +(page_topic11)= +Week 11 Summary +======================= + +This week we will continue our discussion on Graphs and look at two examples of them with code. \ No newline at end of file diff --git a/notes/week12/class12A.md b/notes/week12/class12A.md new file mode 100644 index 0000000..18977c6 --- /dev/null +++ b/notes/week12/class12A.md @@ -0,0 +1,36 @@ +# Class Meeting 12A + +Today we will be working on understanding and exploring the Depth-first algorithm. + +
+ +
+ +[Download the Slides from today](https://github.com/ubc-cs/cpsc203/raw/main/files/Lec18_StateSpaces.pdf) + +## Important links for today: + +- [Solve a Sudoku puzzle](https://www.sudokuonline.io/kids/numbers-4-4) +- [Mathematics of Sudoku](https://en.wikipedia.org/wiki/Mathematics_of_Sudoku) + + + +## Logistics + +1. Clone the Class Activity Repository + +You will first need to "accept" the GitHub Classroom assignment to get a copy of the starter code. + +You can do that by [clicking here](https://classroom.github.com/a/ZEaSSumI). + +Then, clone the `classActivity1XY` repository by running the following line in your Terminal: + +``` +git clone +``` + +## Acknowledgements + +Slides for {{ COURSE_CODE }} were developed and created by [Dr. Cinda Heeren](https://www.cs.ubc.ca/people/cinda-heeren). The current iteration of the course resulted in minor adaptations and updates, but by in large, full credit of these slides belongs to Dr. Cinda Heeren. \ No newline at end of file diff --git a/notes/week12/class12B.md b/notes/week12/class12B.md new file mode 100644 index 0000000..54fd88f --- /dev/null +++ b/notes/week12/class12B.md @@ -0,0 +1,41 @@ +# Class Meeting 12B + +Today we will be try to find the shortest path through some graphs. + +
+ +
+ +[Download the Slides from today](https://github.com/ubc-cs/cpsc203/raw/main/files/Lec18_Maps.pdf) + +## Important links for today: + +- [Solving Dijkstra's Algorithm](https://algo-dijkstra.vercel.app/index.html) +- [Dijkstra's Algorithm](https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm) +- [Graphical explanation of Dijkstra's algorithm](https://www.geeksforgeeks.org/dijkstras-shortest-path-algorithm-greedy-algo-7/) +- [Another graphical explanation of Dijkstra's algorithm](https://www.freecodecamp.org/news/dijkstras-shortest-path-algorithm-visual-introduction/) + + + +## Logistics + +There is no repo to clone today! + + +## Acknowledgements + +Slides for {{ COURSE_CODE }} were developed and created by [Dr. Cinda Heeren](https://www.cs.ubc.ca/people/cinda-heeren). The current iteration of the course resulted in minor adaptations and updates, but by in large, full credit of these slides belongs to Dr. Cinda Heeren. \ No newline at end of file diff --git a/notes/week12/videos.md b/notes/week12/videos.md new file mode 100644 index 0000000..0e0f230 --- /dev/null +++ b/notes/week12/videos.md @@ -0,0 +1,104 @@ +# Videos + +Below are the assigned videos for this week. +The videos are collapsible so once you're done with one, you can move to the next one. +In the sidebar on the right, you can use the checklists to keep track of what's done. + +````{margin} +```{admonition} Checklist of items +:class: tip sticky + + + + + + + + +``` +```` + +## Required Videos + +### Tuesday's Class + +```{dropdown} 1. Searching State Spaces - Depth First Search + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + +```{dropdown} 2. Depth First Search Part 2 + :class-container: sd-shadow-lg + :color: primary + +
+ +
+``` + +```{dropdown} 3. Stacks and Breadth-first search + :class-container: sd-shadow-lg + :color: primary + +
+ +
+``` + +### Thursday's class + +We'll continue the stuff from Tuesday on Thursday. + + +```{dropdown} 4. Single Source Shortest Path + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + +```{dropdown} 5. Dijkstra's Algorithm + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + + diff --git a/notes/week12/week12_summary.md b/notes/week12/week12_summary.md new file mode 100755 index 0000000..890ae18 --- /dev/null +++ b/notes/week12/week12_summary.md @@ -0,0 +1,5 @@ +(page_topic12)= +Week 12 Summary +======================= + +This week we will are talking about State Spaces, and diving deeper into Graphs. \ No newline at end of file diff --git a/notes/week13/class13A.md b/notes/week13/class13A.md new file mode 100644 index 0000000..11b01fc --- /dev/null +++ b/notes/week13/class13A.md @@ -0,0 +1,48 @@ +# Class Meeting 13A + +Today we will be working on using Maps. + +
+ +
+ +[Download the Slides from today](https://github.com/ubc-cs/cpsc203/raw/main/files/Lec19_Maps2.pdf) + +## Important links for today: + +- [Solve a Sudoku puzzle](https://www.sudokuonline.io/kids/numbers-4-4) +- [Mathematics of Sudoku](https://en.wikipedia.org/wiki/Mathematics_of_Sudoku) + + + +## Logistics + +### Installing packages + +You will probably need to install some packages for today's class: + +- `conda install osmnx` +- `conda install networkx` +- `conda install folium` +- `conda install scikit-learn` +- `conda install mapclassify` + +### Cloning a repository + +1. Clone the Class Activity Repository + +You will first need to "accept" the GitHub Classroom assignment to get a copy of the starter code. + +You can do that by [clicking here](https://classroom.github.com/a/qYP0az4U). + +Then, clone the `classActivity1XY` repository by running the following line in your Terminal: + +``` +git clone +``` + +## Acknowledgements + +Slides for {{ COURSE_CODE }} were developed and created by [Dr. Cinda Heeren](https://www.cs.ubc.ca/people/cinda-heeren). The current iteration of the course resulted in minor adaptations and updates, but by in large, full credit of these slides belongs to Dr. Cinda Heeren. \ No newline at end of file diff --git a/notes/week13/class13B.md b/notes/week13/class13B.md new file mode 100644 index 0000000..22bc6e0 --- /dev/null +++ b/notes/week13/class13B.md @@ -0,0 +1,36 @@ +# Class Meeting 13B + +Today we will be working on the Travelling Salesperson problem (the slides are the same as 13A). + +
+ +
+ +[Download the Slides from today](https://github.com/ubc-cs/cpsc203/raw/main/files/Lec19_Maps2.pdf) + + + +## Logistics + + 1. Clone the Class Activity Repository + +You will first need to "accept" the GitHub Classroom assignment to get a copy of the starter code. + +You can do that by [clicking here](https://classroom.github.com/a/LXKH9ZuB). + +Then, clone the `classActivity1XY` repository by running the following line in your Terminal: + +``` +git clone +``` + + +## Acknowledgements + +Slides for {{ COURSE_CODE }} were developed and created by [Dr. Cinda Heeren](https://www.cs.ubc.ca/people/cinda-heeren). The current iteration of the course resulted in minor adaptations and updates, but by in large, full credit of these slides belongs to Dr. Cinda Heeren. \ No newline at end of file diff --git a/notes/week13/videos.md b/notes/week13/videos.md new file mode 100644 index 0000000..ea9fb46 --- /dev/null +++ b/notes/week13/videos.md @@ -0,0 +1,55 @@ +# Videos + +Below are the assigned videos for this week. +The videos are collapsible so once you're done with one, you can move to the next one. +In the sidebar on the right, you can use the checklists to keep track of what's done. + +````{margin} +```{admonition} Checklist of items +:class: tip sticky + + + +``` +```` + +## Required Videos + +### Tuesday's Class + +```{dropdown} 1. Geographical Applications of Maps + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + +### Thursday's class + +The Travelling Salesperson problem (TSP). + +```{dropdown} 2. Travelling Salesperson problem + :class-container: sd-shadow-lg + :color: primary + :open: + +
+ +
+``` + + diff --git a/notes/week13/week13_summary.md b/notes/week13/week13_summary.md new file mode 100755 index 0000000..6adf301 --- /dev/null +++ b/notes/week13/week13_summary.md @@ -0,0 +1,5 @@ +(page_topic13)= +Week 13 Summary +======================= + +This week we will be working with Maps data, a natural application of Graphs. \ No newline at end of file diff --git a/notes/week14/class14A.md b/notes/week14/class14A.md new file mode 100644 index 0000000..e863bde --- /dev/null +++ b/notes/week14/class14A.md @@ -0,0 +1,44 @@ +# Class Meeting 14A + +Today we will be working on visualizing literature + +
+ +
+ +[Download the Slides from today](https://github.com/ubc-cs/cpsc203/raw/main/files/Lec20_LitViz.pdf) + +## Important links for today: + +- [Solve a Sudoku puzzle](https://www.sudokuonline.io/kids/numbers-4-4) +- [Mathematics of Sudoku](https://en.wikipedia.org/wiki/Mathematics_of_Sudoku) + + + +## Logistics + +### Installing packages + +You will probably need to install some packages for today's class: + +- `conda install nltk` + +### Cloning a repository + +1. Clone the Class Activity Repository + +You will first need to "accept" the GitHub Classroom assignment to get a copy of the starter code. + +You can do that by [clicking here](https://classroom.github.com/a/QOTyz_JX). + +Then, clone the `classActivity1XY` repository by running the following line in your Terminal: + +``` +git clone +``` + +## Acknowledgements + +Slides for {{ COURSE_CODE }} were developed and created by [Dr. Cinda Heeren](https://www.cs.ubc.ca/people/cinda-heeren). The current iteration of the course resulted in minor adaptations and updates, but by in large, full credit of these slides belongs to Dr. Cinda Heeren. \ No newline at end of file diff --git a/notes/week14/week14_summary.md b/notes/week14/week14_summary.md new file mode 100755 index 0000000..bf2af66 --- /dev/null +++ b/notes/week14/week14_summary.md @@ -0,0 +1,5 @@ +(page_topic14)= +Week 14 Summary +======================= + +This week we will be demoing some cool examples of Graph Applications. \ No newline at end of file diff --git a/references.bib b/references.bib new file mode 100755 index 0000000..783ec6a --- /dev/null +++ b/references.bib @@ -0,0 +1,56 @@ +--- +--- + +@inproceedings{holdgraf_evidence_2014, + address = {Brisbane, Australia, Australia}, + title = {Evidence for {Predictive} {Coding} in {Human} {Auditory} {Cortex}}, + booktitle = {International {Conference} on {Cognitive} {Neuroscience}}, + publisher = {Frontiers in Neuroscience}, + author = {Holdgraf, Christopher Ramsay and de Heer, Wendy and Pasley, Brian N. and Knight, Robert T.}, + year = {2014} +} + +@article{holdgraf_rapid_2016, + title = {Rapid tuning shifts in human auditory cortex enhance speech intelligibility}, + volume = {7}, + issn = {2041-1723}, + url = {http://www.nature.com/doifinder/10.1038/ncomms13654}, + doi = {10.1038/ncomms13654}, + number = {May}, + journal = {Nature Communications}, + author = {Holdgraf, Christopher Ramsay and de Heer, Wendy and Pasley, Brian N. and Rieger, Jochem W. and Crone, Nathan and Lin, Jack J. and Knight, Robert T. and Theunissen, Frédéric E.}, + year = {2016}, + pages = {13654}, + file = {Holdgraf et al. - 2016 - Rapid tuning shifts in human auditory cortex enhance speech intelligibility.pdf:C\:\\Users\\chold\\Zotero\\storage\\MDQP3JWE\\Holdgraf et al. - 2016 - Rapid tuning shifts in human auditory cortex enhance speech intelligibility.pdf:application/pdf} +} + +@inproceedings{holdgraf_portable_2017, + title = {Portable learning environments for hands-on computational instruction using container-and cloud-based technology to teach data science}, + volume = {Part F1287}, + isbn = {978-1-4503-5272-7}, + doi = {10.1145/3093338.3093370}, + abstract = {© 2017 ACM. There is an increasing interest in learning outside of the traditional classroom setting. This is especially true for topics covering computational tools and data science, as both are challenging to incorporate in the standard curriculum. These atypical learning environments offer new opportunities for teaching, particularly when it comes to combining conceptual knowledge with hands-on experience/expertise with methods and skills. Advances in cloud computing and containerized environments provide an attractive opportunity to improve the effciency and ease with which students can learn. This manuscript details recent advances towards using commonly-Available cloud computing services and advanced cyberinfrastructure support for improving the learning experience in bootcamp-style events. We cover the benets (and challenges) of using a server hosted remotely instead of relying on student laptops, discuss the technology that was used in order to make this possible, and give suggestions for how others could implement and improve upon this model for pedagogy and reproducibility.}, + booktitle = {{ACM} {International} {Conference} {Proceeding} {Series}}, + author = {Holdgraf, Christopher Ramsay and Culich, A. and Rokem, A. and Deniz, F. and Alegro, M. and Ushizima, D.}, + year = {2017}, + keywords = {Teaching, Bootcamps, Cloud computing, Data science, Docker, Pedagogy} +} + +@article{holdgraf_encoding_2017, + title = {Encoding and decoding models in cognitive electrophysiology}, + volume = {11}, + issn = {16625137}, + doi = {10.3389/fnsys.2017.00061}, + abstract = {© 2017 Holdgraf, Rieger, Micheli, Martin, Knight and Theunissen. Cognitive neuroscience has seen rapid growth in the size and complexity of data recorded from the human brain as well as in the computational tools available to analyze this data. This data explosion has resulted in an increased use of multivariate, model-based methods for asking neuroscience questions, allowing scientists to investigate multiple hypotheses with a single dataset, to use complex, time-varying stimuli, and to study the human brain under more naturalistic conditions. These tools come in the form of “Encoding” models, in which stimulus features are used to model brain activity, and “Decoding” models, in which neural features are used to generated a stimulus output. Here we review the current state of encoding and decoding models in cognitive electrophysiology and provide a practical guide toward conducting experiments and analyses in this emerging field. Our examples focus on using linear models in the study of human language and audition. We show how to calculate auditory receptive fields from natural sounds as well as how to decode neural recordings to predict speech. The paper aims to be a useful tutorial to these approaches, and a practical introduction to using machine learning and applied statistics to build models of neural activity. The data analytic approaches we discuss may also be applied to other sensory modalities, motor systems, and cognitive systems, and we cover some examples in these areas. In addition, a collection of Jupyter notebooks is publicly available as a complement to the material covered in this paper, providing code examples and tutorials for predictive modeling in python. The aimis to provide a practical understanding of predictivemodeling of human brain data and to propose best-practices in conducting these analyses.}, + journal = {Frontiers in Systems Neuroscience}, + author = {Holdgraf, Christopher Ramsay and Rieger, J.W. and Micheli, C. and Martin, S. and Knight, R.T. and Theunissen, F.E.}, + year = {2017}, + keywords = {Decoding models, Encoding models, Electrocorticography (ECoG), Electrophysiology/evoked potentials, Machine learning applied to neuroscience, Natural stimuli, Predictive modeling, Tutorials} +} + +@book{ruby, + title = {The Ruby Programming Language}, + author = {Flanagan, David and Matsumoto, Yukihiro}, + year = {2008}, + publisher = {O'Reilly Media} +} diff --git a/requirements.txt b/requirements.txt new file mode 100755 index 0000000..9a2e587 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +docutils==0.17.1 +linkify +linkify-it-py +jupyter-book +matplotlib +numpy \ No newline at end of file diff --git a/tools/ed_discussion/chat.png b/tools/ed_discussion/chat.png new file mode 100644 index 0000000..6f561d9 Binary files /dev/null and b/tools/ed_discussion/chat.png differ diff --git a/tools/ed_discussion/chat2.png b/tools/ed_discussion/chat2.png new file mode 100644 index 0000000..bae08f5 Binary files /dev/null and b/tools/ed_discussion/chat2.png differ diff --git a/tools/ed_discussion/ed_discussion.md b/tools/ed_discussion/ed_discussion.md new file mode 100644 index 0000000..ee91bf8 --- /dev/null +++ b/tools/ed_discussion/ed_discussion.md @@ -0,0 +1,91 @@ +![](../../images/header.jpg) + +(tools_ed_discussion)= +# Ed Discussion + +Hello everyone! + +We will be using Ed Discussion for our class Q&A, it's really great! I hope you like it. + +This is the best place to ask questions about the course, whether about content, or logistics. You should ask every question here, and the only thing you need to decide is whether your question should be public (helps everyone) or private (applies only to you, for e.g., regrade requests, personal circumstances etc...) + +You will get faster answers here from the teaching team as well as other students here on Ed Discussion - all of your TAs are on here as well. Neither TAs nor instructors will be responding to emails or Canvas messages, unless it's a legitimate emergency. + +At various points in the course, I will give you some tips and suggestions on how to more effectively ask for, and give help. + +Here are some tips: + +- Do a quick scan to search before you post, it's possible your question was already asked. If it has, add a response to it, rather than creating a new question + +- Click the heart emoji ❤️ for questions and answers you find/found useful + +- Try to answer questions you feel comfortable answering and just try your best! If it's not quite correct, TAs and instructors will be offering helpful edits and corrections. This will be a learning experience as well. + +- For each questions that were answered by students (high recommended!), the first answer that we think is fully correct, we will "Endorse" it - this means that the answer was approved by an instructor + +- Share interesting course related content with staff and peers - ask lots of questions and let's build a community together! + +Here is a quick overview of the main features of Ed Discussion: + +## 1. Interface + +![](welcome.png) + +## 2. Find and stay up-to-date on your questions + +![](tips.png) + +## 3. How to Post a Question + +Most of the time, you should select "Question" instead of a "Post". +A post can be used for things that you don't necessarily want a response to, sharing of resources, videos, etc... + +![](question.png) + +## 4. How to ask private questions ONLY to the instructor + +To make a post/question Private, simply click on the box that says "Private". You can also post anonymously to other students (but the TAs and instructor will still know who posted). + +![](private.png) + +In general, I suggest asking open and public questions so others can benefit from answers and we can crowd-source knowledge. For questions that you think are private and relevant only to you, you can ask them privately so only the instructors see the question. + +## 5. Use the editor and all its' features + +![](editor.png) + +## 6. Set your notification settings! + +I suggest you enable notification emails so that you get an email when someone replies to your thread or a comment that you made. + +![](notifications.png) + +## 7. Refer to other posts + +Each post has a number associated with it that starts from 1 and counts upwards. You can refer to other posts by using the following syntax: #2. + +Ed Discussion is smart enough to turn that into a link, so that if someone clicks on it, they will get taken to Post #2 (which is this one). + +## 8. (NEW!) Can I contact other students in the class (DM) ? + +Yes - Ed Discussion has a new feature called "Ed Chat" (that's in Early Beta) which allows you to chat with other students in the class, and with the teaching team (when they initiate a conversation). +I have turned this feature on, but I urge you to be respectful of how you approach others. +If you find that this feature is causing you grief, or if you are receiving messages that are inappropriate, please let me know anonymously, and I will turn off the ability to contact your peers. +It is my hope that this new functionality allows you to contact your study group partners, make friends, and build community. +The teaching team may reach out to you via Ed Chat. + +Ed Chat can be accessed from the left sidebar on your course's main discussion page: + +![](chat.png) + +The interface is a bit rough, but the functionality all seems to be there. +You can create a "public channel" that other students can join, or create a "private channel" for situations where you want to control the members in the group. +There is also the ability to send "direct messages (DMs)" directly to one or more students. + +![](chat2.png) + +Let me know if you find this new functionality useful! + +## Quick Start Guide + +Here is a [PDF of the Quick Start Guide to Ed Discussion](https:/edstem.org/quickstart/ed-discussion.pdf). \ No newline at end of file diff --git a/tools/ed_discussion/editor.png b/tools/ed_discussion/editor.png new file mode 100644 index 0000000..bc1d3f0 Binary files /dev/null and b/tools/ed_discussion/editor.png differ diff --git a/tools/ed_discussion/notifications.png b/tools/ed_discussion/notifications.png new file mode 100644 index 0000000..4401e00 Binary files /dev/null and b/tools/ed_discussion/notifications.png differ diff --git a/tools/ed_discussion/private.png b/tools/ed_discussion/private.png new file mode 100644 index 0000000..583029d Binary files /dev/null and b/tools/ed_discussion/private.png differ diff --git a/tools/ed_discussion/question.png b/tools/ed_discussion/question.png new file mode 100644 index 0000000..8be4a6b Binary files /dev/null and b/tools/ed_discussion/question.png differ diff --git a/tools/ed_discussion/tips.png b/tools/ed_discussion/tips.png new file mode 100644 index 0000000..fbb9f42 Binary files /dev/null and b/tools/ed_discussion/tips.png differ diff --git a/tools/ed_discussion/welcome.png b/tools/ed_discussion/welcome.png new file mode 100644 index 0000000..db65587 Binary files /dev/null and b/tools/ed_discussion/welcome.png differ diff --git a/tools/github/branch.png b/tools/github/branch.png new file mode 100644 index 0000000..6535eca Binary files /dev/null and b/tools/github/branch.png differ diff --git a/tools/github/github.md b/tools/github/github.md new file mode 100644 index 0000000..80657e3 --- /dev/null +++ b/tools/github/github.md @@ -0,0 +1,98 @@ +# Git and GitHub + +## GitHub + +### Cloning Repos + +Open a Terminal window, and then run the following command: + +``` +git clone https://github.com/firasm/test.git +``` + +### Pull requests + +Once you have created a branch and "completed" a feature, it's time to merge the feature back to the `main` (or `master`) branch. +Of course, as you learned in the tutorial you can do this yourself, but in general it's a good idea for another teammate to review your work before it is merged into master. +This is where Pull Requests come in: + +To create pull requests (even students working solo can do this), [you can follow Steps 4 and 5 from here](https://guides.github.com/activities/hello-world/#pr), and then assign a reviewer (from your group) to look at your code. + + +From [GitHub's documentation](https://github.com/git-guides): + +> **Issues** are a great way to keep track of tasks, enhancements, and bugs for your projects. They’re kind of like email—except they can be shared and discussed with the rest of your team. Most software projects have a bug tracker of some kind. GitHub’s tracker is called Issues, and has its own section in every repository. + +> **Labels** are a great way to organize different types of issues. Issues can have as many labels as you want, and you can filter by one or many labels at once. + +> **Milestones**, are groups of issues that correspond to a project, feature, or time period. People use them in many different ways in software development. + +> **Assignees** are a great way to filter, categorize issues, and remember what you're responsible to do. Each issue can have an assignee — one person that’s responsible for moving the issue forward. Assignees are selected the same way milestones are, through the grey bar at the top of the issue. You can change or add a milestone, an assignee, and labels by clicking their corresponding gears in the sidebar on the right. + +### Pull changes from `remote`` into `local` + +How to pull the most recent changes to your computer + +If you edit your code on the GitHub web interface, or if another use commits to your repository, to update the repository with the most recent changes, you should **always start a working session by running this command** in your git repository (using either Terminal or GitBash): + +``` +git pull +``` + +This will make sure your local computer is updated with any changes. +If you expect that some of the same files have been edited (or if your `git pull` fails), you can try: + +``` +git pull --no-ff +``` + +Commit and push your changes often while you work to stay in sync. + +### Creating a new release + +[Here](https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/managing-releases-in-a-repository) are the instructions to create a release. + +Briefly, here is how to create a release ([from the docs](https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/managing-releases-in-a-repository)): + +1. On GitHub, navigate to the main page of the repository. + +2. To the right of the list of files, click Releases or Latest release. + + + +3. Click Draft a new release. + +4. Type a version number for your release. Versions are based on Git tags. + +5. Use the drop-down menu to select the branch that contains the project you want to release. + +6. Type a title and description for your release. + +7. Once you're ready to publicize your release, click Publish release. To work on the release later, click Save draft. + +### Semantic Versioning + +When developers (like you!) are working on a software project that others will be using or viewing, they need a way to communicate with their users when new features are released and bugs are fixed. +Typically, this is done by creating **version** and you're likely most familiar with this with your phone or laptop operating system (OS). +For instance, if you have an iPhone the latest version of your OS is 14.2.1 - what do the 14, 2 and 1 mean? +There are conventions, and the one that I suggest you follow is: [Semantic Versioning](https://semver.org). + +From [semver.org](https://semver.org), here is the summary: + +Given a version number MAJOR.MINOR.PATCH, increment the: + +1. MAJOR version when you make incompatible API changes, +1. MINOR version when you add functionality in a backwards compatible manner, and +1. PATCH version when you make backwards compatible bug fixes. + +## Git + +GitHub has a [handy cheat sheet](https://education.github.com/git-cheat-sheet-education.pdf) available. + +Here are some relevant screenshots from that cheat sheet: + +![](setup.png) + +![](stage.png) + +![](branch.png) \ No newline at end of file diff --git a/tools/github/setup.png b/tools/github/setup.png new file mode 100644 index 0000000..8c0c8bc Binary files /dev/null and b/tools/github/setup.png differ diff --git a/tools/github/stage.png b/tools/github/stage.png new file mode 100644 index 0000000..559a139 Binary files /dev/null and b/tools/github/stage.png differ