Welcome to The Carpentries Etherpad! This pad is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents. Use of this service is restricted to members of the Software Carpentry and Data Carpentry community; this is not for general purpose use (for that, try etherpad.wikimedia.org). Users are expected to follow our code of conduct: https://docs.carpentries.org/topic_folders/policies/code-of-conduct.html All content is publicly available under the Creative Commons Attribution License: https://creativecommons.org/licenses/by/4.0/ https://pad.carpentries.org/2018-09-26-UCL http://socrative.com/ RITS PYTHON setup: http://rits.github-pages.ucl.ac.uk/2018-09-26-UCL_software_carpentry/python/ def favorite_ice_cream(): ice_creams = [ "chocolate", "vanilla", "strawberry" ] print(ice_creams[3]) favorite_ice_cream() def normalize_rectangle(rect): '''Normalizes a rectangle so that it is at the origin and 1.0 units long on its longest axis.''' assert len(rect) == 4, 'Rectangles must contain 4 coordinates' x0, y0, x1, y1 = rect assert x0 < x1, 'Invalid X coordinates' assert y0 < y1, 'Invalid Y coordinates' dx = x1 - x0 dy = y1 - y0 if dx > dy: scaled = float(dx) / dy upper_x, upper_y = 1.0, scaled else: scaled = float(dx) / dy upper_x, upper_y = scaled, 1.0 assert 0 < upper_x <= 1.0, 'Calculated upper X coordinate invalid' assert 0 < upper_y <= 1.0, 'Calculated upper Y coordinate invalid' return (0, 0, upper_x, upper_y) SHELL Data: http://swcarpentry.github.io/shell-novice/data/data-shell.zip pwd = print working directory cd = change directory ~ = takes you to your home directory = (same if you don't put anything) /home/name/a/particular/path = takes you to a particular path .. = it takes you to the directory above ls = list files -F = shows a '/' after the directories -a = shows the "hidden" files -l = long description of the files/directories -l *.pdb = shows only the files that end with ".pdb" -l ?ethane.pdb = shows what has only one letter before "ethane.pdb" rm = remove files -r = (for recursive) remove a directory cp = copy files mv = move files mv thesis/drafts.txt . = moves draft from thesis to here "." wc = counts words -c = counts characters -c *.pdb = count characters for all the files ending with ".pdb" -w = counts words -l = counts lines cat = displays or concatenate the file less = displays the file more = like less, but keeps the text on screen sort = sort lines -n = sorts by numbers head = shows the first few lines of a file -n 20 = shows the first 20 lines tail = shows the last lines of a file -n 20 = shows the last 20 lines | = is a symbol to "pipe" the ouput of a command as input for the next one > filname = ouputs will be saved into a filename >> filename = ouputs will be appended into a filename for variable in *.dat do ls $variable done Loops over all the files on *.dat, then list that particular file. nano filename = Opens a file called filename with the nano text editor; ^ = Ctrl key. To create a script you can write commands into a filename, where $1 is the first argument, $2 is the second, ... e.g., grep = find text on files