Practice Problems

Lecture 1

Answer each number in a separate cell

Rename this notebook with your last name and the (2 digit) lecture number.

ex. Cych_01

Turn-in this notebook on triton-ed by 5pm tomorrow.

  1. Practice with inserting cells

    • launch jupyter notebook and make a new notebook called YOURLASTNAME_PPnumber
    • Insert a cell.
    • Change it to ‘Markdown’ and type some notes. You can just type most things, but special features like Section headers, bullets, numbered lists and other fun things require special formatting. For a pretty good explanation see this link:
    • Run the cell to typeset your notes. If you want to change them, just double click on the cell, type away, then 'run' it again.
  2. Practice with markdown cells

    • If you see plain text in one of the cells in the lecture notebooks, just double click on it and all will be revealed. Try double clicking on THIS cell to see how to make bulleted lists
    • then run it.
  3. Practice with code cells

    • Insert another cell, keeping it the default of Code.

    • type in the cell: print("Hello World")

    • run that cell.
  4. Commands within a jupyter notebook

    • Create a directory called Practice.
    • List the contents of the current directory.
    • Remove the directory Practice.
    • List the contents of the current directory again.

Turn in your notebook using TritonEd. For this first lecture, you have until 5pm tomorrow. Make sure your notebook has the correct name. You will recieve a ZERO if 1) the notebook doesn't work. 2) it has the wrong name. 3) is turned in after the deadline. 4) you obviously copied from somebody else. Do your own work!

Further practice outside of the notebook. This will not be graded but eventually you will have to know how to do these things, so you might as well practice them now!

  1. Commands on the command line

    • Open up a terminal window (or anaconda prompt on PCs).
    • Print out your current directory with pwd.
    • Use mkdir to create a new folder
    • cd into that folder
    • Use cat (or type on PCs) to write your name into a file called testfile.txt use the syntax:
      • cat > myfile.txt
      • Brendan Cych [type in your own name here!]
      • To finish the task, you must press on the control key and 'D' at the same time (control C on a PC).
    • Use cat (or type) again (with no redirect) to see the contents of your file.
    • Create a file currentDirectory.txt with a list of the folders and files in the current directory
    • Make a folder called Practice
    • Move the file currentDirectory.txt to the folder Practice
      • use the command: mv oldfilepath newfilepath
    • Remove the file currentDirectory.txt
    • Print a list of your current directory
  2. Make an executable python script.

    • use cat > to write a python script (or type on PCs).
      • Your python script should print "Hello World"
      • Remember: to finish, hold down control and D (or C on PCs) at the same time
    • Run your script with python
    • If on a Mac,
      • edit your script to include the #!/usr/bin/env python line at the top
      • use chmod to make the script executable
    • execute your script from the command line.
In [ ]: