20.181:Materials:OH1 notes: Difference between revisions

From OpenWetWare
Jump to navigationJump to search
mNo edit summary
Line 3: Line 3:
Downloaded some code off the web: fib_module.py
Downloaded some code off the web: fib_module.py


This file defines a function called calc_fib that we will use.
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.)
(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.)

Revision as of 09:54, 8 September 2006

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.
  • 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