VIB Technology
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Introduction to programming and Python ## Objectives 1. Begin to understand programming and computing. What are "building blocks"? How are building blocks "glued" together? 1. Evaluate some simple Python expressions on various data types. 1. Recognise error messages, comprehend them, and fix the problem they're describing. 1. Understand what a variable is how how to use them. 1. How are non-integer real numbers represented. Understand that using them can be dangerous. 1. How to perform type conversions. 1. How to perform some simple I/O with `input()` and `print()`. ## Materials 1. Jupyter and the "Basics", "Functions", and "Conditions" notebooks. 1. The "How to Design Programs" textbook. ## Procedure **10:05** The basics of programming and computing. SAY: By way of providing you with some background. Our objective for the first 2 sessions today is to provide you with a way of thinging about programming and computing in general. The ideas we want to present you with apply to all programming and programming languages even though we will be using Python for examples. So for those of you who are already familiar with R or other programming languages, we hope you will still find these 2 sessions useful. SAY: A note for those of you who are already confident programmers. This morning may feel slow for you. We're covering the basics. Feel free to read ahead and complete the advanced exercises. If you are a new programmer please follow along with me. There are a lot of new concepts that we will cover today and you will feel exhausted soon enough. We need not rush. CMD: Read out the quote from "How to Design Programs" > When you were a small child, your parents taught you to count > and perform simple calculations with your fingers [..]. They > would ask "what's 3 + 2?" and you would count off the fingers > on one hand. They programmed and you computed. And in some > way, that's really all there is to programming and computing. SAY: Now we're going to do some programming in the same way. We'll ask some simple arithmetic questions, and the computer will compute the answers and print the results. That's how simple programming is. You ask questions of your programming environment (in this case, Python), and it computes for you. RUN: With the students, explain again how to execute a cell and verify each answer. Also explain what `abs()` is doing. SAY: The first cell here just contains a number. Run it. What happens? Yes, numbers evaluate to themselves. `1` evaluates to `1`. `256` evaluates to `256`. When you execute a cell containing a more complicated expression, like `3 + 2` a similar thing happens. First the left-hand operand (`3`) is evaluated, it evaluates to itself in this case. Then the right-hand operand is evaluated (`2`), then the operation (`+`) is evaluated with the evaluated operands. Continue to evaluate these cells and convince yourself that you understand what each operator is doing. Modify the operands as you wish. SAY: Remember the order of operations. In school I learned as mnemonic (BODMAS): first brackets, then functions, then divide and multiply, and finally add and subtract. This order of operations also applies in computer programming to ensure mathematical expressions are evaluated correctly. SAY: Don't worry, there's more to programming than mathematics. So if the maths scares you fear not for there is very little in this course. Maths is just useful when showing you the _building blocks_, the fundamental units used for constructing your programs and primitive operations on these building blocks (+, *, /, abs(), etc.). One of those units (or types) are _numbers_, another is _text_, _images_, signals from _key presses_, or _mouse movements_, and many many more. Let's look at another one of these types, TEXT. Units of text are often called _strings_ because the computer represents them as a series of _characters_ strung together. What do you think the primitive `+` operation does when applied to strings? What about `*`? Let's find out... RUN: Let students run the examples and find out what these operations do for themselves. SAY: The final building blocks we will explore in this section are the logical (Boolean; named after the self-taught English mathematician [George Boole](https://en.wikipedia.org/wiki/George_Boole)) values and comparison operators. The logical values are `True` and `False`. Like numbers and strings, they evaluate to themselves. There are several logical operators: locical conjunction performed with the `and` operator in Python. Logical disjunction performed with the `or` operator in Python. Finally, logical not performed with the `not` operator in Python. CMD: Show truth tables in from [link](https://philosophy.lander.edu/logic/conjunct.html). Then allow students to predict the outcome of each cell. SAY: The outcome of a comparison operation is a Boolean value. These operations can be read as questions: Is `5` less than `10`? "Yes", or `True`. CMD: Complete the exercises SAY: Now you've done some programming. And your computer has done some computing. You've earned a break. I'll start again in 10 minutes. If you have questions during the break, Tuur and I will be here. If at any point you feel lost or left behind please tell Tuur or myself either in the public chat or by private message. We have a lot to cover and many (if not all) of the concepts we talk about will be new to you. There is no shame in asking for help. Unfortunately we're not all in a room together so we cannot see if you are struggling or not. **10:30** Break **10:40** Variables. SAY: Now that we're familiar with some of the building blocks of programming. Variables provide us a way to start gluing them together into larger parts. You can think of a variable as a box for a value, and that box has a name, e.g. _mySequence_. You put something into the box using the special _assignment operator_ that Python has kindly provided for us. You can get that value back out simply by evaluating the box. SAY: Let's examine an example in detail: We create a box called "myVar" and put the value `5` in it using the assignment operator. Then we want to evaluate the expression `myVar + myVar`. To do so Python first evaluates the left-hand operand, it opens the box and looks at the value inside, it's `5`. So the left-hand operand evaluates to `5`. The same happens for the right-hand operand. Python opens the box and finds `5` inside. Then Python can reduce the expression to `5 + 5`. If you evaluate this cell, Python should compute the result `10`. SAY: What do you expect the second cell to evaluate to? CMD: Read the text in the notebook. **12:00** Lunch **13:00** Functions * Mention Curry-Howard Isomorphism **14:00** Break **14:15** Conditions **16:00** Break **16:15** Select and work on your project. ## Assessment

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully