Archives For Programming

Computer programming (often shortened to programming, scripting, or coding) is the process of designing, writing, testing, debugging, and maintaining the source code of computer programs. This source code is written in one or more programming languages (such as C++, C#, Java, Python, Smalltalk, etc.). The purpose of programming is to create a set of instructions that computers use to perform specific operations or to exhibit desired behaviors. The process of writing source code often requires expertise in many different subjects, including knowledge of the application domain, specialized algorithms and formal logic.

MIT 6.00SC Lecture 3

gerarddolan —  February 23, 2013 — Leave a comment

mitx_med

“MIT OpenCourseWare (OCW) is a web-based publication of virtually all MIT course content. OCW is open and available to the world and is a permanent MIT activity.”

The following are my notes for this program:

Introduction to Computer Science & Programming

Guttag, John. 6.00SC Introduction to Computer Science and Programming,Spring 2011. (Massachusetts Institute of Technology: MIT OpenCourseWare), http://ocw.mit.edu (Accessed 23 Feb, 2013). License: Creative Commons BY-NC-SA

MIT 600 Lecture 3:
Operators and operands; statements; branching, conditionals, and iteration

Lecturers: Eric Grimson & John Guttag
Course Web site

 

Lecture 03

3 different items required to write code:

1.Data
* Numbers
* strings
* booleans

2. Operations
* addition & multiplication
* and / or
* etc

3. Commands
* assignment
* input / output
* conditionals aka branches
* loop mechanisms

In talks to date, conversation around good programming style
* using comments
* type discipline (operands)
* descriptive use of good variable names
* testing all branches

Focus on this session:

COMMON PATTERNS OF CODE
Iterative approach, structure;
* choose a variable that is going to “count”
* initialize it outside of the loop
* setup the right end test (includes variable)
* construct the block of code (incs changing the variable)
* decide on what to do upon completion

TOOLS TO USE
* create a flow chart
* classes of computation (simple to complex)
* simulatation of the code
* exhaustive enumeration (trying all reasonable values until complete)

Tuple: An order sequence of elements
* foo = (1,2,3,4)
* selection foo[0]
* slicing foo [1,5]

Strings are an ordered sequence of characters as well

Touring complete language are captured with:
* Data
* Operations
* Commands

 

MIT 6.00SC Lecture 2

gerarddolan —  February 18, 2013 — Leave a comment

mitx_med

“MIT OpenCourseWare (OCW) is a web-based publication of virtually all MIT course content. OCW is open and available to the world and is a permanent MIT activity.”

The following are my notes for this program:

Introduction to Computer Science & Programming

Guttag, John. 6.00SC Introduction to Computer Science and Programming,Spring 2011. (Massachusetts Institute of Technology: MIT OpenCourseWare), http://ocw.mit.edu (Accessed 18 Feb, 2013). License: Creative Commons BY-NC-SA

MIT 600 Lecture 2:
Operators and operands; statements; branching, conditionals, and iteration

Lecturers: Eric Grimson & John Guttag
Course Web site

 

 

Lecture 02

2 Fundamental for designing programs* some representation of fundamental data
* a way to give instructions to the computer

Primitive Data =
* numbers
* strings
for these we have a value & a type

Combine in expressions:
* operand
* operators

Interp:
* Eval
* Prints

Script – no printing unless explicit

Type checking – different languages fall on a spectrum of Strong to Weak

Type Discipline:
a) checking out operators or procedures to see what they do under different circumstances
b) what type of arguements or operands to apply to operators

Operator Precedence:
when in doubt use paranthesis

Variables & Values:
done by assigning an Assignment statement

Where can you Variables?
used anywhere that its legal to use the value

Statements =
legal commands that Python can interpret
i.e. Print, Assignment

Sequence of 28 keywords excluded in Python

Straight line programs vs
Branching Programs; is something that can change the order of a program based on a test

Colon identifies a block
Equal sign is an assignment

Test Cases
Have one for each path of the code

Boolean Combination
and, or, not

MIT 6.00SC Lecture 1

gerarddolan —  February 17, 2013 — Leave a comment

mitx_med

“MIT OpenCourseWare (OCW) is a web-based publication of virtually all MIT course content. OCW is open and available to the world and is a permanent MIT activity.”

The following are my notes for this program:

Introduction to Computer Science & Programming

Guttag, John. 6.00SC Introduction to Computer Science and Programming,Spring 2011. (Massachusetts Institute of Technology: MIT OpenCourseWare), http://ocw.mit.edu (Accessed 17 Feb, 2013). License: Creative Commons BY-NC-SA

MIT 600 Lecture 1:
Goals of the course; what is computation; introduction to data types; operators; and variables

Lecturers: Eric Grimson & John Guttag
Course Web site

 

Lecture 01
Course Goals: Develop skills for:
* Computational Thinking
* Understand code
* Understand abilities & Limits
* Map problems into computation
* Libraries = Code written by others
* Help you think like a computer scientist: “How do i write a piece of code that would help me solve this?”

What is computation?
1. Declarative: Statement of fact
2. Imperative: A description of how to do something

* Earliest computers were fixed program computers; i.e. a Calculator
* John Vincent Atanasoff (1941) linear equations

A stored program computer consists of:
1. Memory (contains a sequence of instructions)
2. Control Unit
3. ALU; Arithmetic logic unit
* A program is a recipe
* “With 6 primitives I can code anything” Alan Turing

The 3 dimensions of a programming language;
(There is no best programming language; this course uses Python)
1. High Level vs Low Level language;
~determined by how close are you to the guts of a machine.
2. General vs a Targeted Language;
~ do the primitives support a board range of applications vs a limited set
3. An Interrupted vs a Compiled Language;
~ With Interrupted, source code runs directly to interrupter towards an output.
~ With Compiled, source code runs to intermediate step, a checker / compiler , that creates object code. Considered faster.

Syntax vs Semantics;
* Syntax; What the legal expressions of this language?
* Static Semantics; What programs are meaningful?
* Semantics: What does the program mean?

Python: 2 Types of Values;
* Numbers:integers & floating points
* Strings;