20.181:Materials:OH1 notes

From OpenWetWare

(Redirected from 20.181:OH1)
Jump to: navigation, search

Python/Emacs/Shell refresher tutorial featuring:
Five different ways to do the fibonacci sequence

Downloaded some code off the web: fib_module.py

This file defines a function called calc_fib that we will use in method 1.

(In this class we will often start with a big code base that someone else has developed, and we will write some small part which utilizes this pre-existing code. When you are supposed to hijack others' code, you will be told to do so explicitly and the code will be provided to you. In all other cases, using code you found on the internets is not acceptable. So please don't.)

For this tutorial we'll be working on emacs. Emacs is like pico (which you used last term), the text editor on athena, except with more functionality. But you can use whichever you're comfortable with. A few additional emacs tips:

  • cntl-Z to step out of emacs without killing it, then type "fg" (stands for foreground) to step back in.
your changes won't be lost when you do this, but if you want to run the new version of your file, cntl-x cntl-s to save the chances before stepping out.
  • emacs find and replace function
    • M-% (alt-shift-5)
    • you have to have your cursor at the top of the file
    • space bar to accept change and keep finding
    • more info on find and replace

python code written during office hours, with some associated comments: OH1_commentedcode.txt

Personal tools