DOC PREVIEW
Berkeley COMPSCI 61A - Lecture 2

This preview shows page 1-2-3-4-5-6-7-8-9-10-11-74-75-76-77-78-79-80-81-82-83-149-150-151-152-153-154-155-156-157-158-159 out of 159 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 159 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

61A Lecture 2Monday, August 29Monday, August 29, 2011The Elements of Programming2Monday, August 29, 2011The Elements of Programming•Primitive Expressions and StatementsThe simplest building blocks of a language2Monday, August 29, 2011The Elements of Programming•Primitive Expressions and StatementsThe simplest building blocks of a language•Means of CombinationCompound elements are built from simpler ones2Monday, August 29, 2011The Elements of Programming•Primitive Expressions and StatementsThe simplest building blocks of a language•Means of CombinationCompound elements are built from simpler ones•Means of AbstractionCompound elements can be named and manipulated as units2Monday, August 29, 2011The Elements of Programming•Primitive Expressions and StatementsThe simplest building blocks of a language•Means of CombinationCompound elements are built from simpler ones•Means of AbstractionCompound elements can be named and manipulated as units2Programming languages allow us to communicate, tooMonday, August 29, 2011Functions and DataData: Stuff we want to manipulate3Monday, August 29, 2011Functions and DataData: Stuff we want to manipulate3Functions: Rules for manipulating dataMonday, August 29, 2011Functions and DataData: Stuff we want to manipulate32Functions: Rules for manipulating dataMonday, August 29, 2011Functions and DataData: Stuff we want to manipulate32“The Art of Computer Programming”Functions: Rules for manipulating dataMonday, August 29, 2011Functions and DataData: Stuff we want to manipulate32“The Art of Computer Programming”Donald KnuthFunctions: Rules for manipulating dataMonday, August 29, 2011Functions and DataData: Stuff we want to manipulate32“The Art of Computer Programming”Donald KnuthThis slideFunctions: Rules for manipulating dataMonday, August 29, 2011Functions and DataData: Stuff we want to manipulate32“The Art of Computer Programming”Donald KnuthThis slideFunctions: Rules for manipulating dataAdd numbersMonday, August 29, 2011Functions and DataData: Stuff we want to manipulate32“The Art of Computer Programming”Donald KnuthThis slideFunctions: Rules for manipulating dataAdd numbersCount the words in a line of textMonday, August 29, 2011Functions and DataData: Stuff we want to manipulate32“The Art of Computer Programming”Donald KnuthThis slideFunctions: Rules for manipulating dataAdd numbersPronounce someone’s nameCount the words in a line of textMonday, August 29, 2011Functions and DataData: Stuff we want to manipulate32“The Art of Computer Programming”Donald KnuthThis slideFunctions: Rules for manipulating dataAdd numbersPronounce someone’s nameCount the words in a line of text(Ka-NOOTH)Monday, August 29, 2011Functions and DataData: Stuff we want to manipulate32“The Art of Computer Programming”Donald KnuthThis slideFunctions: Rules for manipulating dataAdd numbersPronounce someone’s nameCount the words in a line of textLoad the next slide(Ka-NOOTH)Monday, August 29, 2011Types of expressions4An expressiondescribes a computationand evaluates to a valueMonday, August 29, 201118 + 69Types of expressions4An expressiondescribes a computationand evaluates to a valueMonday, August 29, 201118 + 69623Types of expressions4An expressiondescribes a computationand evaluates to a valueMonday, August 29, 201118 + 69623√3493161Types of expressions4An expressiondescribes a computationand evaluates to a valueMonday, August 29, 201118 + 69623√3493161sin πTypes of expressions4An expressiondescribes a computationand evaluates to a valueMonday, August 29, 201118 + 69623√3493161sin π| − 1869|Types of expressions4An expressiondescribes a computationand evaluates to a valueMonday, August 29, 201118 + 69623√3493161sin π100�i=1i| − 1869|Types of expressions4An expressiondescribes a computationand evaluates to a valueMonday, August 29, 201118 + 69623√3493161sin π100�i=1i| − 1869|�6918�Types of expressions4An expressiondescribes a computationand evaluates to a valueMonday, August 29, 201118 + 69623√3493161sin πf(x)100�i=1i| − 1869|�6918�Types of expressions4An expressiondescribes a computationand evaluates to a valueMonday, August 29, 201118 + 69623√3493161sin πf(x)100�i=1i| − 1869|�6918�Types of expressions4An expressiondescribes a computationand evaluates to a valueMonday, August 29, 2011Call Expressions in PythonAll expressions can use function call notation(Demo)5Monday, August 29, 2011Anatomy of a Call Expression6Monday, August 29, 2011Anatomy of a Call Expression6add ( 2 , 3 )Monday, August 29, 2011Anatomy of a Call Expression6add ( 2 , 3 )OperatorMonday, August 29, 2011Anatomy of a Call Expression6add ( 2 , 3 )Operator Operand 0 Operand 1Monday, August 29, 2011Anatomy of a Call Expression6add ( 2 , 3 )Operator Operand 0 Operand 1Operators and operands are expressionsMonday, August 29, 2011Anatomy of a Call Expression6add ( 2 , 3 )Operator Operand 0 Operand 1Operators and operands are expressionsSo they evaluate to valuesMonday, August 29, 2011Anatomy of a Call Expression6Evaluation procedure for call expressions:add ( 2 , 3 )Operator Operand 0 Operand 1Operators and operands are expressionsSo they evaluate to valuesMonday, August 29, 2011Anatomy of a Call Expression6Evaluation procedure for call expressions:add ( 2 , 3 )Operator Operand 0 Operand 1Operators and operands are expressions1. Evaluate the operator and operand subexpressionsSo they evaluate to valuesMonday, August 29, 2011Anatomy of a Call Expression6Evaluation procedure for call expressions:add ( 2 , 3 )Operator Operand 0 Operand 1Operators and operands are expressions1. Evaluate the operator and operand subexpressions2. Apply the function that is the value of the operator subexpression to the arguments that are the values of the operand subexpressionSo they evaluate to valuesMonday, August 29, 2011mul(add(2, mul(4, 6)), add(3, 5))Evaluating Nested Expressions7Monday, August 29, 2011mul(add(2, mul(4, 6)), add(3, 5))Evaluating Nested Expressions7Monday, August 29, 2011mul(add(2, mul(4, 6)), add(3, 5))Evaluating Nested Expressions7mulMonday, August 29, 2011mul(add(2, mul(4, 6)), add(3, 5))add(2, mul(4, 6))Evaluating Nested Expressions7mulMonday, August 29, 2011mul(add(2, mul(4,


View Full Document

Berkeley COMPSCI 61A - Lecture 2

Documents in this Course
Lecture 1

Lecture 1

68 pages

Midterm

Midterm

5 pages

Midterm

Midterm

6 pages

Lecture 35

Lecture 35

250 pages

Lecture 14

Lecture 14

125 pages

Lecture 6

Lecture 6

113 pages

Lecture 3

Lecture 3

162 pages

Homework

Homework

25 pages

Lecture 13

Lecture 13

117 pages

Lecture 29

Lecture 29

104 pages

Lecture 11

Lecture 11

173 pages

Lecture 7

Lecture 7

104 pages

Midterm

Midterm

6 pages

Midterm

Midterm

6 pages

Lecture 8

Lecture 8

108 pages

Lab 4

Lab 4

4 pages

Lecture 7

Lecture 7

52 pages

Lecture 20

Lecture 20

129 pages

Lecture 15

Lecture 15

132 pages

Lecture 9

Lecture 9

95 pages

Lecture 30

Lecture 30

108 pages

Lecture 17

Lecture 17

106 pages

Load more
Download Lecture 2
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 2 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 2 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?