Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Projektgruppe

(15 min)

Danne en projektgruppe med max 4 personer. Vælg et navn til deres gruppe, som kan gerne være sjovt. Følge Classroom50 group assignments og:

Accepter project opgaven.

RobotLab certification

(120 min)

  1. Gennemføre UR e-learning modul. Modulen vil formodentlig tage omkring 1.5-2 time. Certifikaterne skal afleveres som gruppe i project repositorium sådan:

    certs/s123456.pdf
    certs/s123457.pdf
    ...
  2. Gå til http://engtech.dtu.dk/designbuildlab og læse de generelle regler for brug af laboratorier, under Generel info => Sikkerhed og regler for brug.

Coding environment continued

(30 min)

Git installation

We will use Git to communicate with the repositories on GitHub.

Windows
MacOS

Open a terminal and run:

winget install git.git

After installation, set your name. Use the mail address you used for GitHub.[1].

git config --global user.name "YOUR NAME"

Then your email:

git config --global user.email "YOUR_EMAIL"

Python installation

Run the following in the terminal:

MacOS
Windows
brew install python

Editor extension installation

Run the following in the terminal:

codium --install-extension ms-python.python --install-extension ms-python.black-formatter --install-extension ms-pyright.pyright --install-extension github.vscode-pull-request-github

Folder structure for the semester

Every project, will have its own folder and repository, e.g., repository1 and repository2. Based on this, my recommended directory structure is:

📁 your home folder, e.g., /Users/u/
├── 📁 Desktop
    ├── 📁 uni
        ├── 📁 26WS
            ├── 📁 indprog
                ├── 📁 code
                    ├── 📁 repository1
                    ├── 📁 repository2
                    ├── 📁 ...

You can create this structure using the following command in terminal:

Windows
MacOS & Linux
mkdir Desktop\uni\26WS\indprog\code

Running programs in the editor

  1. Start the editor.

  2. Open a terminal using the menu Terminal → New Terminal or CtrlShift`:

  3. The following command will change your directory to your code folder and clone the template repository into your code folder. Change the path to your code folder if you have a different structure.

    In the terminal, change your directory to the code folder:

    cd Desktop/uni/26WS/indprog/code

    And then copy the template repository into your code folder, called clone:

    git clone https://github.com/indprog/python-template-multi

    After cloning, you should see:

  4. In our editor, opening a project means opening the folder containing the projects files. These are in our case repository1, repository2, and not code folder.

    Open the folder that we cloned with git in the editor using File -> Open Folder:

  5. We trust each other, so click Manage

  6. Click Add Folder instead of Trust to trust the whole code folder[2]:

    Select the code folder and click Trust Folder. You should see:

    Close Workspace Trust window.

  7. On the left activity bar, click griddy-icons:files Explorer and click the folder src-> hello.*.

  8. We will now build and run the code using the debugger. Press F5 or Run -> Start Debugging. You should see:

    If you don’t see the emoji on Windows, refer here: Configuring PowerShell for rendering special symbols.

  9. You can also try a program with input. Click the file pi-estimator.* and run it.

The assignments will have their own repository, which you will clone into your code folder. We will practice this in the next lecture.

Reading & exercises

From Think Python notebooks do Chapter 1 and 2. To run the notebooks, you need to sign in with a Google account.

At the end of the reading you try to explain the following concepts and why they are important for Python programming. If you have doubts, note them and write them in Discussions, and move on. We will focus on these points in the next lecture.

Chapter 1

  • Programming as a way of thinking

  • Arithmetic operators

    • integers and floating-point numbers

    • division using / and //

  • Expressions

    • Paranthesis in arithmetic expressions

    • Every expression has a value

  • Arithmetic functions

    • round, abs

    • calling a function using ()

    • SyntaxError

  • Strings

    • Defining a string using single or double quotes

    • plus operation on strings -- concatenation

    • multiplication on strings

    • len

    • Errors if other quotes are used

  • Values and types

    • type

    • Conversion between types using int, float, str

    • TypeError if you, e.g., try to add a string and an integer

    • _ separator in numbers

  • Formal and natural languages

    • Ambiguity vs exactness, redundancy

    • Debugging Chapter 2

  • Variables and statements

    • Assignment (variable = expression)

    • Variables can be used in functions round(x)

    • State diagrams (we used them in flowchart drawings)

    • Valid variable names

    • import

    • Using variables in a module, e.g., math.pi

  • Expressions and statements

    • Definition and difference

    • print

    • print(x, y, z)

  • Arguments

    • Optional arguments

    • Endless number of arguments, e.g., print(x, y, z, ...)

  • Comments

    • # for comments

    • Density of formal languages is sometimes not comprehensible

    • Comprehensible (and long) variable names vs short (but readable in complex expressions) variable names

  • Debugging

    • Syntax, runtime vs semantic errors

We meet in Robotlab G2.61 and classroom nearby G2.58

Robotlabben kan ikke holde så mange studerende, så vi vil dele hele holdet i to grupper – mens den ene halvdel arbejder med robotterne, vil den anden gruppe arbejde i det tilstødende lokale.

Footnotes
  1. Because we will add additional repositories to the code folder.