[ Main ] [ Home ] [ Work ] [ Code ] [ Rants ] [ Readings ] [ Links ] 



{Latest update: 26 March 2010}

Introduction
Course from MIT OpenCourseWare introducing the basic concepts of Computer Science and programming. Its aims are to provide with an understanding of the role of computation in solving problems, as well as a basic ability to write some small programs. The Python programming language is used as a tool during the class, both in order to illustrate the concepts and to write the programs. This course is taught by Prof. Eric Grimson and Prof. John Guttag. The general reference texts for this course are:
Additional information can be obtained from the course's homepage. Lecture 1
Goals of the course; what is computation; introduction to data types, operators, and variables.
Goals of the course
Skills to develop:
What is computation
Data types, operators and variables
Lecture 2
Operators and operands; statements; branching, conditionals, and iteration. Handout (PDF).
Operators and operands
Elements needed when writing a program:
Overall concepts about operators and operands:
Statements
Branching, conditionals, iterations
x = 15 if (x/2)*2 == x: print 'Even' print 'Even' else: print 'Odd' y=0 x=3 itersLeft = x while(itersLeft>0): y=y+x itersLeft = itersLeft  1 #print 'y =',y,',itersLeft=',itersLeft print y
Lecture 3
Common code patterns: iterative programs. Handout (PDF)
Review
Overview:
Good programming practices:
Iterative programs
Elements of iterative programs:
Tools:
Exhaustive enumeration:
For loop:
Tuple: ordered sequence of elements (inmutable): >>> test = (1,2,3,4) >>> test (1, 2, 3, 4) >>> test[0] 1 >>> test[1] # selecting 2 >>> test[10] Traceback (most recent call last): File " Tuples can be concatenated: x = 100 divisors = () for i in range (1,x): if x%i == 0: divisors = divisors + (i) Strings also support selection and slicing: >>> s1 = 'abcdefg' >>> s2 = 'hijklmn' >>> s1 'abcdefg' >>> s1[0] 'a' >>> s1+s2 'abcdefghijklmn' >>> s1[2:4] 'cd' >>> s1[:5] 'abcde' All this makes it possible to manipulate strings: sumDigits = 0 for c in str(1952): sumDigits += int (c) print sumDigits These tools also make it possible for us to use the set of commands from the table above to compute anything that can be expressed in an algorithm (the concept of a Turing machine). 