EX00 - Getting Started


Welcome to COMP110 - Introduction to Programming at UNC Chapel Hill!

This exercise will guide you through setting up your computer for the course, registering for required services, setting up a workspace, and writing your first program.

1. Register for Course Services

Next, register for a few services the course depends upon for office hours, backing up your work, and for submitting assignments.

2. Software Setup

Begin by working through the software setup instructions found in the Resources section of the website.

3. Setup a Workspace Repository

Your code, most that you will write entirely on your own and some which extends starting points we provide, will be organized in a workspace repository. This makes it easy to download new course material and to backup your work. Continue by setting up your workspace repository.

4. Write Your First Program!

Now for the main attraction! Let’s write a classic “hello world” program.

In Visual Studio Code, be sure your workspace is open. (Reminder: File > Open Recent > comp110-workspace-onyen is a quick way to reopen it!)

Open the Explorer pane (click the icon with two sheets of paper or to to View > Explorer) and expand the Workspace and comp110 directories to look like this:

Right click on the exercises directory and select “New File”. Enter the following filename, being careful to match capitalization and punctuation:

  • ex00_getting_started.py

An empty file opens. The .py file extension is standard for Python programs.

For the past 50 or more years it’s a tradition in the programming world for your first program to print the words “Hello, world.” We won’t break it.

Write the line of code below in your file:

Next, save your program (shortcuts on Windows: Control+S, Mac: Command+S).

Now, run your program by opening the command palette (shortcuts on Windows: Control+Shift+P, Mac: Command+Shift+P) and typing “Start without Debugging” and pressing Enter.

The terminal will pop up, if it wasn’t already there. If you see some cryptic text followed by a line that contains only “Hello, world.” followed by another prompt, that means it worked! Humble beginnings.

Try changing the text inside of the double quotes (but be sure to keep the words hello and world somewhere), saving again, and rerunning your program.

What is this line of code doing? You are calling a function named print. The print function is built-in to the Python programming language and results in data being “printed” out somewhere. By default, that somewhere is on your screen in the terminal. The parentheses following the word print indicate extra information being given to the print function. In this example, you are giving a piece of textual information to print called a “string” denoted by the double quotes surrounding the textual data. Don’t worry, we will break down all of this into more tangible detail soon!

Your first program is almost complete! However, before submitting it on Gradescope there are a couple more style and documentation steps to complete.

First, you should add a special kind of string value, called a docstring short for documentation string, to the top of your program file, called a module in Python. Then, you should add a line with a special variable named __author__ assigned to be your 9-digit student PID. (Disclaimer: Out in the real world the __author__ variable is typically your name and e-mail address, but since we will grade your programs we’d like to avoid potential bias in seeing your names as part of the programs as we’re grading.) Add the following lines above the line of code that calls the print function. Fill in your 9-digit UNC PID number, without any spaces or dashes, in the __author__ string.

Save your program again and re-run it. You should still only see your printed output message. What must that mean about the two lines of code you just added? They’re for documentation purposes and must not impact the printed output of the program.

Make a Backup Checkpoint “Commit”

Now that your first program is complete, let’s practice making a backup. Visual Studio Code has built-in support for git source control management (SCM). SCM tools are made to help create versioned checkpoints of a project’s source code (your program is source code!) amont other uses. In 2020, the de facto SCM is called git. As one more piece of terminology, a checkpointed version in git is called a commit. Once your work is in a commit checkpoint, you can always return back to your project at that point in time without the risk of losing work. We encourage committing work to backup at least each time you submit a project for grading or are finishing out a working session for the day. Commits are free to make and can only help you avoid losing work; use them liberally!

  1. Open the Source Control panel (Command Palette: “Show SCM” or click the icon with three circles and lines on the activity panel).
  2. Notice the files listed under Changes. These are files you’ve made modifications to since your last backup.
  3. Move your mouse’s cursor over the word Changes and notice the + symbol that appears. Click that plus symbol to add all changes to the next backup. You will now see the files listed under “Staged Changes”.
    • If you do not want to backup all changed files, you can select them individually. For this course you’re encouraged to back everything up.
  4. In the Message box, give a brief description of what you’ve changed and are backing up. This will help you find a specific backup (called a “commit”) if needed. In this case a message such as, “Finished Exercise 00!” will suffice.
  5. Press the Check icon to make a Commit (a version) of your work.
  6. Finally, press the Ellipses icon (…) and select “Push” to send this backed up version to your workspace repository space on GitHub.

To see your commit on Github, in a web browser, navigate to https://github.com/comp110-20ss2/comp110-workspace-USERNAME and substitute USERNAME with your GitHub username. Open the comp110 directory, then exercises, and ex0_getting_started.py you’ll see the work you just completed backed up to GitHub. Notice above the file’s content’s you’ll see your commit message.

Submit to Gradescope for Grading

All that’s left now is to hand-in your work on Gradescope for grading! Before doing so you need to know that before an assignment’s deadline you can resubmit work without penalty. Portions of assignments are autograded and will provide near-immediate feedback. We want you to resubmit as many times as it takes you in order to earn full autograding credit!

Login to Gradescope and select the assignment named “EX00 - Getting Started”. You’ll see an area to upload a zip file. To produce a zip file for autograding, return back to Visual Studio Code.

If you do not see a Terminal at the bottom of your screen, open the Command Palette and search for “View: Toggle Integrated Terminal”.

Type the following command (all on a single line):

python -m tools.submission comp110/exercises/ex00_getting_started.py

In the file explorer pane, look to find the zip file named “20.mm.dd-hh.mm-submission.zip”. The “mm”, “dd”, and so on, are timestamped with the current month, day, hour, minute. If you right click on this file and select “Reveal in File Explorer” on Windows or “Reveal in Finder” on Mac, the zip file’s location on your computer will open. Upload this file to Gradescope to submit your work for this exercise.

Autograding will take a few moments to complete. For this exercise there will be no “human graded” component, but in future exercises and projects there will. Thus, you should expect to score 100 out of 100 possible points on this assignment. If there are issues reported, you are encouraged to try and resolve them and resubmit. If for any reason you aren’t receiving full credit and aren’t sure what to try next, come give us a visit in office hours!

Congratulations!

There were a lot of steps and new concepts thrown at you in this initial exercise. Gearing up is half the battle! The amount of setup involved in a modern development environment can be a little overwhelming to a first-time programmer. You are not expected to understand the intricacies of the processes and software you just follwed and setup. That will come with time. For now, focus on the big win that is having written a Python program in a professional code editor, run it, and backed it up using git! Programming gets way more fun, and way more creatively rewarding, as we make our way up the mountain from here.