List of projects for day 1#

Introduction to python#

Get the notebook used for the introduction to Python and go through the examples.

Project Euler#

Go to https://projecteuler.net/. It’s a website offering a collection of mathy programming challenges, starting from very simple ones and ending with very hard ones. The first 10-20 problems are a great playground for playing with a new programming language. The problems above 50-100 require advanced knowledge of math and algorithms.

Loading and plotting 2D data in various ways#

In this exercise you will use python to read (real!) data from a file, and plot it in various ways. For this you will use the python packages numpy and matplotlib.

In particular, you will work with 2D data, i.e. data that depends on two parameters. Such data is often stored using three arrays: Two 1D arrays X and Y, and one 2D array C such that for the parameters X[i] and Y[j] the data is stored in C[j, i] (Note the order of i and j here - in this convention the x-coordinate in the matrix is along the rows, i.e. varying the column index).

In this exercise, you will work with two sets of 2D data, Rxx and RH, that depend on the same parameters (For those who are interested, I give a background below. It’s not necessary to understand that background, though).

Depending on your ambition, you can load the data in an easy way (where we did the work for you), or doing it the harder way from the raw data.

Easy way#

The files X.dat and Y.dat contain the values of the x and y parameters, and Rxx.dat and RH.dat are the two different sets of data for the same parameters. Those files are formatted in a way that you can simply load them with numpy.loadtxt.

Harder way#

The file landaufan.dat contains the raw data. The first column is the x parameter, the second column is the y parameter, the fourth column is Rxx, and the fifth column is RH.

There are also rows without data, such as comment lines starting with a #. Read the data from the file, and make a 2D numpy array for Rxx and RH.

Tasks#

  • Load the data

  • Make a 2D plot of the data using matplotlib. Check the functions pcolor, pcolormesh and imshow

  • Plot linecuts through the data, i.e. depending only on one parameter, keeping the other parameter fixed

  • Plot a set of line cuts in one plot (use loops)

  • Plot line cuts from both data sets into one plot

  • Plot the data as is or divided by 12906.

  • Be creative!

Physics background#

The data was measured by Arjan Beukmann. He measured the longitudinal resistance (Rxx in units of Ohms) and the Hall resistance (RH in units of Ohms) as a function of gate voltage (X) and magnetic field (Y in Tesla).

Processing data#

The following ten data sets contain different Rxx as a function of B. B is stored in the first column, Rxx is stored in the fourth column:

SdH1.dat, SdH2.dat, SdH3.dat, SdH4.dat, SdH5.dat, SdH6.dat, SdH7.dat, SdH8.dat, SdH9.dat, SdH10.dat

Tasks#

  • Read the data into numpy arrays

  • Compute the Fourier transform of Rxx as a function of 1/B for one data set. Use various ranges of B (e.g. only for B>0.2)

  • Harder: Do this for all data sets and combine all 10 data sets into a 2D plot. (The data sets have different length, so this is not straight-forward)

Physics background#

The data was measured by Arjan Beukmann. He measured the longitudinal resistance (Rxx in units of Ohms) as a function of magnetic field (B in Tesla).

Basic cryptography#

Caesar’s cipher#

The following text is encrypted by shifting all letters in the alphabet by a fixed amount (e.g. a shift by 2 would give A -> C, B -> D, …, Z -> B). Decrypt it by trying out all possible shifts! (Just copy the assignment below to use the text in your python program)

encrypted_text1 = """
RW. XMJWQTHP MTQRJX, BMT BFX ZXZFQQD AJWD QFYJ NS YMJ RTWSNSLX, XFAJ ZUTS YMTXJ
STY NSKWJVZJSY THHFXNTSX BMJS MJ BFX ZU FQQ SNLMY, BFX XJFYJI FY YMJ GWJFPKFXY YFGQJ.
N XYTTI ZUTS YMJ MJFWYM-WZL FSI UNHPJI ZU YMJ XYNHP BMNHM TZW ANXNYTW MFI QJKY GJMNSI
MNR YMJ SNLMY GJKTWJ. NY BFX F KNSJ, YMNHP UNJHJ TK BTTI, GZQGTZX-MJFIJI, TK YMJ XTWY
BMNHM NX PSTBS FX F "UJSFSL QFBDJW." OZXY ZSIJW YMJ MJFI BFX F GWTFI XNQAJW GFSI SJFWQD
FS NSHM FHWTXX. "YT OFRJX RTWYNRJW, R.W.H.X., KWTR MNX KWNJSIX TK YMJ H.H.M.," BFX
JSLWFAJI ZUTS NY, BNYM YMJ IFYJ "1884." NY BFX OZXY XZHM F XYNHP FX YMJ TQI-KFXMNTSJI
KFRNQD UWFHYNYNTSJW ZXJI YT HFWWD—INLSNKNJI, XTQNI, FSI WJFXXZWNSL. 

"BJQQ, BFYXTS, BMFY IT DTZ RFPJ TK NY?" 
"""

Substitution cipher#

Now let’s look at a more complicated cipher where we replace (uniquely) every letter by some random letter. Decrypt the following text!

encrypted_text2 = """
  "IEGG ZE, DMISTW, DBMI FT RTN ZMOE TQ TNY LPSPITY'S SIPHO? SPWHE DE BMLE XEEW ST
NWQTYINWMIE MS IT ZPSS BPZ MWF BMLE WT WTIPTW TQ BPS EYYMWF, IBPS MHHPFEWIMG STNLEWPY
XEHTZES TQ PZJTYIMWHE. GEI ZE BEMY RTN YEHTWSIYNHI IBE ZMW XR MW EUMZPWMIPTW TQ PI."
  "P IBPWO," SMPF P, QTGGTDPWV MS QMY MS P HTNGF IBE ZEIBTFS TQ ZR HTZJMWPTW, "IBMI FY.
ZTYIPZEY PS M SNHHESSQNG, EGFEYGR ZEFPHMG ZMW, DEGG-ESIEEZEF SPWHE IBTSE DBT OWTD BPZ
VPLE BPZ IBPS ZMYO TQ IBEPY MJJYEHPMIPTW."
  "VTTF!" SMPF BTGZES. "EUHEGGEWI!"
  "P IBPWO MGST IBMI IBE JYTXMXPGPIR PS PW QMLTNY TQ BPS XEPWV M HTNWIYR JYMHIPIPTWEY
DBT FTES M VYEMI FEMG TQ BPS LPSPIPWV TW QTTI."
  "DBR ST?"
  "XEHMNSE IBPS SIPHO, IBTNVB TYPVPWMGGR M LEYR BMWFSTZE TWE BMS XEEW ST OWTHOEF MXTNI
IBMI P HMW BMYFGR PZMVPWE M ITDW JYMHIPIPTWEY HMYYRPWV PI. IBE IBPHO-PYTW QEYYNGE PS
DTYW FTDW, ST PI PS ELPFEWI IBMI BE BMS FTWE M VYEMI MZTNWI TQ DMGOPWV DPIB PI."
  "JEYQEHIGR STNWF!" SMPF BTGZES.
  "MWF IBEW MVMPW, IBEYE PS IBE 'QYPEWFS TQ IBE H.H.B.' P SBTNGF VNESS IBMI IT XE IBE
STZEIBPWV BNWI, IBE GTHMG BNWI IT DBTSE ZEZXEYS BE BMS JTSSPXGR VPLEW STZE SNYVPHMG
MSSPSIMWHE, MWF DBPHB BMS ZMFE BPZ M SZMGG JYESEWIMIPTW PW YEINYW."
  "YEMGGR, DMISTW, RTN EUHEG RTNYSEGQ," SMPF BTGZES, JNSBPWV XMHO BPS HBMPY MWF GPVBIPWV
M HPVMYEIIE. "PWIEYESIPWV, IBTNVB EGEZEWIMYR," SMPF BE MS BE YEINYWEF IT BPS QMLTNYPIE
HTYWEY TQ IBE SEIIEE. "IBEYE MYE HEYIMPWGR TWE TY IDT PWFPHMIPTWS NJTW IBE SIPHO.
PI VPLES NS IBE XMSPS QTY SELEYMG FEFNHIPTWS."
  "BMS MWRIBPWV ESHMJEF ZE?" P MSOEF DPIB STZE SEGQ-PZJTYIMWHE. "P IYNSI IBMI IBEYE PS
WTIBPWV TQ HTWSEANEWHE DBPHB P BMLE TLEYGTTOEF?"
  "P MZ MQYMPF, ZR FEMY DMISTW, IBMI ZTSI TQ RTNY HTWHGNSPTWS DEYE EYYTWETNS."
"""

Use frequency analysis and for example the frequency of bigrams.

email/twitter bot#

Most of the things you know are programmable. As an example projects, write a program that would get or send email messages, or perhaps make posts in twitter.

arxiv#

Can you count who authored the most papers on e.g. http://arxiv.org/archive/cond-mat in the last month?`