Upload
others
View
4
Download
0
Embed Size (px)
Citation preview
61A Lecture 1
Friday, August 24, 2012
Welcome to Berkeley Computer Science!
2
The Course Staff
3
The Course Staff
3
The Course Staff
3
The Course Staff
3
0 1 2 3 4 5 years
The Course Staff
3
0 1 2 3 4 5 years
TAs run sections, labs, and also everything else
The Course Staff
3
0 1 2 3 4 5 years
TAs run sections, labs, and also everything else
The Course Staff
3
0 1 2 3 4 5 years
TAs run sections, labs, and also everything else
Readers are your personal programming mentors
The Course Staff
3
0 1 2 3 4 5 years
TAs run sections, labs, and also everything else
Readers are your personal programming mentorsLab Assistants ensure that you don’t get stuck
What is Computer Science?
4
What is Computer Science?
Systems
4
What is Computer Science?
Systems
Artificial Intelligence
4
What is Computer Science?
Systems
Artificial Intelligence
Graphics
4
What is Computer Science?
Systems
Artificial Intelligence
Graphics
Security
4
What is Computer Science?
Systems
Artificial Intelligence
Graphics
Security
Networking
Programming Languages
Theory
Scientific Computing
...
4
What is Computer Science?
Systems
Artificial Intelligence
Graphics
Security
Networking
Programming Languages
Theory
Scientific Computing
...
4
What is Computer Science?
Systems
Artificial Intelligence
Graphics
Security
Networking
Programming Languages
Theory
Scientific Computing
...
4
Computer Vision
What is Computer Science?
Systems
Artificial Intelligence
Graphics
Security
Networking
Programming Languages
Theory
Scientific Computing
...
4
Computer Vision
Planning
What is Computer Science?
Systems
Artificial Intelligence
Graphics
Security
Networking
Programming Languages
Theory
Scientific Computing
...
4
Computer Vision
Planning
Robotics
What is Computer Science?
Systems
Artificial Intelligence
Graphics
Security
Networking
Programming Languages
Theory
Scientific Computing
...
4
Computer Vision
Planning
Robotics
Natural Language Processing
What is Computer Science?
Systems
Artificial Intelligence
Graphics
Security
Networking
Programming Languages
Theory
Scientific Computing
...
4
Computer Vision
Planning
Robotics
Natural Language Processing
...
What is Computer Science?
Systems
Artificial Intelligence
Graphics
Security
Networking
Programming Languages
Theory
Scientific Computing
...
4
Computer Vision
Planning
Robotics
Natural Language Processing
...
What is 61A?
5
What is 61A?
• A course about managing complexity
5
What is 61A?
• A course about managing complexity
Mastering abstraction
5
What is 61A?
• A course about managing complexity
Mastering abstraction
Not about 1’s and 0’s
5
What is 61A?
• A course about managing complexity
Mastering abstraction
Not about 1’s and 0’s
• An introduction to Python
5
What is 61A?
• A course about managing complexity
Mastering abstraction
Not about 1’s and 0’s
• An introduction to Python
All the features we really need: introduced today
5
What is 61A?
• A course about managing complexity
Mastering abstraction
Not about 1’s and 0’s
• An introduction to Python
All the features we really need: introduced today
Understanding through implementation
5
What is 61A?
• A course about managing complexity
Mastering abstraction
Not about 1’s and 0’s
• An introduction to Python
All the features we really need: introduced today
Understanding through implementation
Programs that run other programs: meta-evaluation
5
What is 61A?
• A course about managing complexity
Mastering abstraction
Not about 1’s and 0’s
• An introduction to Python
All the features we really need: introduced today
Understanding through implementation
Programs that run other programs: meta-evaluation
• A challenging course that will demand a lot of you
5
What is 61A?
6
Plone Conference. Photo courtesy of Kriszta Szita
Alternatives to 61A
7
Alternatives to 61A
7
CS 61AS: Self-paced 61A
Alternatives to 61A
7
CS 10: The Beauty and Joy of Computing
CS 61AS: Self-paced 61A
Course Policies
8
Course Policies
8
The purpose of this course is to help you learn
Course Policies
The staff is here to make you successful
8
The purpose of this course is to help you learn
Course Policies
The staff is here to make you successful
8
The purpose of this course is to help you learn
All the details are online:
http://inst.eecs.berkeley.edu/~cs61A/fa12/about.html
Collaboration
9
Collaboration
• Discuss everything with each other
9
Collaboration
• Discuss everything with each other
• EPA: Effort, participation, and altruism
9
Collaboration
• Discuss everything with each other
• EPA: Effort, participation, and altruism• Homework can be completed with a partner
9
Collaboration
• Discuss everything with each other
• EPA: Effort, participation, and altruism• Homework can be completed with a partner
• Projects should be completed with a partner
9
Collaboration
• Discuss everything with each other
• EPA: Effort, participation, and altruism• Homework can be completed with a partner
• Projects should be completed with a partner
• Find a project partner in your section!
9
Collaboration
• Discuss everything with each other
• EPA: Effort, participation, and altruism• Homework can be completed with a partner
• Projects should be completed with a partner
• Find a project partner in your section!
9
The limits of collaboration
Collaboration
• Discuss everything with each other
• EPA: Effort, participation, and altruism• Homework can be completed with a partner
• Projects should be completed with a partner
• Find a project partner in your section!
9
• One simple rule: don’t share code
The limits of collaboration
Collaboration
• Discuss everything with each other
• EPA: Effort, participation, and altruism• Homework can be completed with a partner
• Projects should be completed with a partner
• Find a project partner in your section!
9
• One simple rule: don’t share code
• Copying project solutions is a serious offense!
The limits of collaboration
Announcements
10
Announcements
• Next week, both section and lab will meet in the lab rooms.
10
Announcements
• Next week, both section and lab will meet in the lab rooms.
• Homework 1 is posted! All homework is graded on effort.
10
Announcements
• Next week, both section and lab will meet in the lab rooms.
• Homework 1 is posted! All homework is graded on effort.
• If you are on the waitlist, still complete assignments!
10
Announcements
• Next week, both section and lab will meet in the lab rooms.
• Homework 1 is posted! All homework is graded on effort.
• If you are on the waitlist, still complete assignments!
• Midterms are on 9/19 and 10/24. Final exam is on 12/13.
10
Announcements
• Next week, both section and lab will meet in the lab rooms.
• Homework 1 is posted! All homework is graded on effort.
• If you are on the waitlist, still complete assignments!
• Midterms are on 9/19 and 10/24. Final exam is on 12/13.
• Read the lecture notes before you come to lecture!
10
Announcements
• Next week, both section and lab will meet in the lab rooms.
• Homework 1 is posted! All homework is graded on effort.
• If you are on the waitlist, still complete assignments!
• Midterms are on 9/19 and 10/24. Final exam is on 12/13.
• Read the lecture notes before you come to lecture!
10
Types of expressions
11
An expression
describes a computation
and evaluates to a value
18 + 69
Types of expressions
11
An expression
describes a computation
and evaluates to a value
18 + 696
23
Types of expressions
11
An expression
describes a computation
and evaluates to a value
18 + 696
23 p3493161
Types of expressions
11
An expression
describes a computation
and evaluates to a value
18 + 696
23 p3493161
sin⇡
Types of expressions
11
An expression
describes a computation
and evaluates to a value
18 + 696
23 p3493161
sin⇡
|� 1869|
Types of expressions
11
An expression
describes a computation
and evaluates to a value
18 + 696
23 p3493161
sin⇡
100X
i=1
i
|� 1869|
Types of expressions
11
An expression
describes a computation
and evaluates to a value
18 + 696
23 p3493161
sin⇡
100X
i=1
i
|� 1869|
✓69
18
◆
Types of expressions
11
An expression
describes a computation
and evaluates to a value
18 + 696
23 p3493161
sin⇡
f(x)100X
i=1
i
|� 1869|
✓69
18
◆
Types of expressions
11
An expression
describes a computation
and evaluates to a value
18 + 696
23 p3493161
sin⇡
f(x)100X
i=1
i
|� 1869|
✓69
18
◆
Types of expressions
11
An expression
describes a computation
and evaluates to a value
Call Expressions in Python
All expressions can use function call notation
(Demo)
12
Anatomy of a Call Expression
13
Anatomy of a Call Expression
13
add ( 2 , 3 )
Anatomy of a Call Expression
13
add ( 2 , 3 )
Operator
Anatomy of a Call Expression
13
add ( 2 , 3 )
Operator Operand 0 Operand 1
Anatomy of a Call Expression
13
add ( 2 , 3 )
Operator Operand 0 Operand 1
Operators and operands are expressions
Anatomy of a Call Expression
13
add ( 2 , 3 )
Operator Operand 0 Operand 1
Operators and operands are expressions
So they evaluate to values
Anatomy of a Call Expression
13
Evaluation procedure for call expressions:
add ( 2 , 3 )
Operator Operand 0 Operand 1
Operators and operands are expressions
So they evaluate to values
Anatomy of a Call Expression
13
Evaluation procedure for call expressions:
add ( 2 , 3 )
Operator Operand 0 Operand 1
Operators and operands are expressions
1. Evaluate the operator and operand subexpressions
So they evaluate to values
Anatomy of a Call Expression
13
Evaluation procedure for call expressions:
add ( 2 , 3 )
Operator Operand 0 Operand 1
Operators and operands are expressions
1. Evaluate the operator and operand subexpressions
2. Apply the function that is the value of the operator subexpression to the arguments that are the values of the operand subexpression
So they evaluate to values
mul(add(2, mul(4, 6)), add(3, 5))
Evaluating Nested Expressions
14
mul(add(2, mul(4, 6)), add(3, 5))
Evaluating Nested Expressions
14
mul(add(2, mul(4, 6)), add(3, 5))
Evaluating Nested Expressions
14
mul
mul(add(2, mul(4, 6)), add(3, 5))
add(2, mul(4, 6))
Evaluating Nested Expressions
14
mul
mul(add(2, mul(4, 6)), add(3, 5))
add(2, mul(4, 6))
Evaluating Nested Expressions
14
mul
add
mul(add(2, mul(4, 6)), add(3, 5))
add(2, mul(4, 6))
Evaluating Nested Expressions
14
mul
add 2
mul(add(2, mul(4, 6)), add(3, 5))
add(2, mul(4, 6))
Evaluating Nested Expressions
14
mul
add 2mul(4, 6)
mul(add(2, mul(4, 6)), add(3, 5))
add(2, mul(4, 6))
Evaluating Nested Expressions
14
mul
add 2mul(4, 6)
mul 4 6
mul(add(2, mul(4, 6)), add(3, 5))
add(2, mul(4, 6))
Evaluating Nested Expressions
14
mul
add 2mul(4, 6)
mul 4 6
24
mul(add(2, mul(4, 6)), add(3, 5))
add(2, mul(4, 6))
Evaluating Nested Expressions
14
26mul
add 2mul(4, 6)
mul 4 6
24
mul(add(2, mul(4, 6)), add(3, 5))
add(2, mul(4, 6))
Evaluating Nested Expressions
14
26mul
add 2mul(4, 6)
mul 4 6
24
add(3, 5)
mul(add(2, mul(4, 6)), add(3, 5))
add(2, mul(4, 6))
Evaluating Nested Expressions
14
26mul
add 2mul(4, 6)
mul 4 6
24
add(3, 5)
add 3 5
mul(add(2, mul(4, 6)), add(3, 5))
add(2, mul(4, 6))
Evaluating Nested Expressions
14
26mul
add 2mul(4, 6)
mul 4 6
24
add(3, 5)
add 3 5
8
208mul(add(2, mul(4, 6)), add(3, 5))
add(2, mul(4, 6))
Evaluating Nested Expressions
14
26mul
add 2mul(4, 6)
mul 4 6
24
add(3, 5)
add 3 5
8
Data, Functions, and Interpreters
15
Data, Functions, and Interpreters
Data: The things that programs fiddle with
15
Data, Functions, and Interpreters
Data: The things that programs fiddle with
15
2
Data, Functions, and Interpreters
Data: The things that programs fiddle with
15
2“The Art of Computer Programming”
Data, Functions, and Interpreters
Data: The things that programs fiddle with
15
2“The Art of Computer Programming”
Donald Knuth
Data, Functions, and Interpreters
Data: The things that programs fiddle with
15
2“The Art of Computer Programming”
Donald KnuthShakespeare’s 37 plays
Data, Functions, and Interpreters
Data: The things that programs fiddle with
15
2“The Art of Computer Programming”
Donald KnuthShakespeare’s 37 plays
Functions: Rules for manipulating data
Data, Functions, and Interpreters
Data: The things that programs fiddle with
15
2“The Art of Computer Programming”
Donald KnuthShakespeare’s 37 plays
Functions: Rules for manipulating data
Add up numbers
Data, Functions, and Interpreters
Data: The things that programs fiddle with
15
2“The Art of Computer Programming”
Donald KnuthShakespeare’s 37 plays
Functions: Rules for manipulating data
Add up numbers
Count the words in a line of text
Data, Functions, and Interpreters
Data: The things that programs fiddle with
15
2“The Art of Computer Programming”
Donald KnuthShakespeare’s 37 plays
Functions: Rules for manipulating data
Add up numbersPronounce someone’s name
Count the words in a line of text
Data, Functions, and Interpreters
Data: The things that programs fiddle with
15
2“The Art of Computer Programming”
Donald KnuthShakespeare’s 37 plays
Functions: Rules for manipulating data
Add up numbersPronounce someone’s name
Count the words in a line of text
(Ka-NOOTH)
Data, Functions, and Interpreters
Data: The things that programs fiddle with
15
2“The Art of Computer Programming”
Donald KnuthShakespeare’s 37 plays
Functions: Rules for manipulating data
Add up numbersPronounce someone’s name
Count the words in a line of text
(Ka-NOOTH)
Interpreter: An implementation of the procedure for evaluation