Home Practicum 1 Practicum 2 Practicum 3 Practicum 4 Practicum 5 Practicum 6 Practicum 7 Practicum 8 Practicum 9 Practicum 10

Welcome to DS2000 CS practicum!

Today we'll make sure you have the software necessary to start learning Python and we'll write our first program in Python! If you're interested in the papers or code that I talked about in the intro, you can download the slides. Now, let's get started.

  1. Getting a CCIS account
  2. Installing Python 3.7.1 for Windows
  3. Installing Python 3.7.1 for MacOS
  4. Writing your first program
  5. Preparing your program for submission
  6. Arithmetic operations
  7. Variables

Getting a CCIS account

You will need a CCIS account both to use the computers in the lab and to hand in the assignment. If you haven't already done so, go to https://www.khoury.northeastern.edu/systems/getting-started/ to request your CCIS account. It should be quite fast might take up to a few hours. Go ahead with the rest of the exercise while you're waiting for approval.

If you requested access but did not get it during the class, please just send your assignment to my email: sapiezynski@gmail.com.

Installing Python 3.7.1 for Windows

> Show instructions

Installing Python 3.7.1 for Mac

> Show instructions

Writing your first program

  1. Start IDLE
  2. Create a new scrpt (File > New File)
  3. You will see something like this:
  4. Type: print('Hello world') in the script.
  5. Save the script to your computer as hello.py. I suggest you create a folder structure to keep your work organized, see the Homework Handout from the lecture for pointers on how to do it. For example, save it in your home folder in ds2000/practicum/pr01.
  6. Run the code by pressing F5 (or Fn+F5 on a Mac).
  7. Do you see something like this in your interpreter?
  8. If yes, congratulations, you ran your first program! If you get an error message, it's not a big deal! All programmers constantly get errors. Learning how to read and understand the error messages is an important part of programming. Please ask the professor or the teaching assistant for help.

Preparing your program for submission

  1. In this practicum we will follow the same code style as for your homeworks. It looks like this:
  2. Modify this template in the specified location to write a program that prints your name (you can also print your preferred pronoun):
    Spring 2019
    PR01 - hello world, my name is...
    def main():
    	# Print your name instead of "hello world"
    	# you can also print your preferred pronoun
    	# ENTER CODE BELOW THIS LINE (1-2 lines)
  3. Save the file in the same folder you created earlier as hello_name.py.
  4. Make sure that the program runs with no errors and prints what you intended.
  5. It's quite likely you will get an error along the lines of expected an indented block. We'll get into this more during the next practicum, for now you will need to remember that Python is sensitive to whitespaces (invisible characters that you produce by pressing the Space and Tab keys). Make sure that all the lines in the definition of your def main(): function start with the same indent, specifically a single Tab, but that the call to the actual function (the last line that says main()) has no indent.
  6. Follow the instructions from the Homework Handout to zip and submit your practicum code.
  7. That's it for the graded part of this week's practicum. If you're ready before time, continue to the next session. Otherwise, don't worry, we'll have more time to do it next week!

Arithmetic operations

This section is not graded, so don't worry if you don't manage to go through it in the practicum.

The interpreter window can be used to run (or evaluate) simple statements. Let's first use it as a calculator:

  1. In the interpreter (Directly in the IDLE window, not in a file) type the following commands (skipping the >>> characters) and see the output:
    >>> 3 + 5
    >>> 3 - 5
    >>> 3 * 5
    >>> 3 / 5
  2. There are also other arithmetic operators available, such as:
    • exponent (power) **:
      >>> 2 ** 3
      >>> 2 ** 4
    • floor division (skips the decimal digits, compare the output to regular division) //:
      >>> 10 // 3
      >>> 10 / 3
    • modulus (returns the remainder of the division operation) %:
      >>> 10 % 3 	# 10 = 3 * 3 + 1, where 1 is the reminder
      >>> 11 % 3 	# 11 = 3 * 3 + 2, where 2 is the reminder
      >>> 12 % 3 	# 12 = 4 * 3 + 0, where 0 is the reminder


This section is not graded, so don't worry if you don't manage to go through it in the practicum.

Variables can be used to store values, such as numbers:

>>> x = 5
>>> x
  1. Create a variable called y to hold value of 3.
  2. Try running x + y.
  3. You can also use variables to store results of operations. Try z = x + y. Print the value of z.
  4. Variables don't have to have single letter names and they can store other values than numbers. Try today = 'Wednesday'. Print the value of today