150
61A Lecture 1 Wednesday, August 26, 2015

61A Lecture 1 - wla.berkeley.edu

  • Upload
    others

  • View
    9

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 61A Lecture 1 - wla.berkeley.edu

61A Lecture 1

Wednesday, August 26, 2015

Page 2: 61A Lecture 1 - wla.berkeley.edu

Welcome to Berkeley Computer Science!

2

Page 3: 61A Lecture 1 - wla.berkeley.edu

Soda Hall

Welcome to Berkeley Computer Science!

2

Page 4: 61A Lecture 1 - wla.berkeley.edu

Soda Hall

Welcome to Berkeley Computer Science!

2

John DeNero

Page 5: 61A Lecture 1 - wla.berkeley.edu

Soda Hall

Welcome to Berkeley Computer Science!

2

John DeNero

How to contact me:

Page 6: 61A Lecture 1 - wla.berkeley.edu

Soda Hall

Welcome to Berkeley Computer Science!

2

John DeNero

How to contact me:

[email protected]

Page 7: 61A Lecture 1 - wla.berkeley.edu

Soda Hall

Welcome to Berkeley Computer Science!

2

John DeNero

How to contact me:

[email protected]

piazza.com/berkeley/fall2015/cs61a

Page 8: 61A Lecture 1 - wla.berkeley.edu

Soda Hall

Welcome to Berkeley Computer Science!

2

John DeNero

Fall 2015 office hours:

How to contact me:

[email protected]

piazza.com/berkeley/fall2015/cs61a

Page 9: 61A Lecture 1 - wla.berkeley.edu

Soda Hall

Welcome to Berkeley Computer Science!

2

John DeNero

Fall 2015 office hours:

781 Soda

How to contact me:

[email protected]

piazza.com/berkeley/fall2015/cs61a

Page 10: 61A Lecture 1 - wla.berkeley.edu

Soda Hall

Welcome to Berkeley Computer Science!

2

John DeNero

Fall 2015 office hours:

781 Soda

Monday 3pm-4pm

How to contact me:

[email protected]

piazza.com/berkeley/fall2015/cs61a

Page 11: 61A Lecture 1 - wla.berkeley.edu

Soda Hall

Welcome to Berkeley Computer Science!

2

John DeNero

Fall 2015 office hours:

781 Soda

Monday 3pm-4pm

Thursday 10am-11am

How to contact me:

[email protected]

piazza.com/berkeley/fall2015/cs61a

Page 12: 61A Lecture 1 - wla.berkeley.edu

Soda Hall

Welcome to Berkeley Computer Science!

2

John DeNero

Fall 2015 office hours:

781 Soda

Monday 3pm-4pm

Thursday 10am-11am

How to contact me:

[email protected]

piazza.com/berkeley/fall2015/cs61a

Page 13: 61A Lecture 1 - wla.berkeley.edu

Soda Hall

Welcome to Berkeley Computer Science!

2

John DeNero

Fall 2015 office hours:

781 Soda

Monday 3pm-4pm

Thursday 10am-11am

Fridays by appointment

How to contact me:

[email protected]

piazza.com/berkeley/fall2015/cs61a

Page 14: 61A Lecture 1 - wla.berkeley.edu

Soda Hall

Welcome to Berkeley Computer Science!

2

John DeNero

Fall 2015 office hours:

781 Soda

Monday 3pm-4pm

Thursday 10am-11am

Fridays by appointmentdenero.org/meet

How to contact me:

[email protected]

piazza.com/berkeley/fall2015/cs61a

Page 15: 61A Lecture 1 - wla.berkeley.edu

The Course Staff

3

Page 16: 61A Lecture 1 - wla.berkeley.edu

The Course Staff

3

40+ Teaching Assistants (GSIs/UGSIs) run labs, discussions, and office hours

Page 17: 61A Lecture 1 - wla.berkeley.edu

The Course Staff

3

40+ Teaching Assistants (GSIs/UGSIs) run labs, discussions, and office hours

30+ Tutors are your personal programming mentors

Page 18: 61A Lecture 1 - wla.berkeley.edu

The Course Staff

3

40+ Teaching Assistants (GSIs/UGSIs) run labs, discussions, and office hours

30+ Tutors are your personal programming mentors

150+ Lab Assistants ensure that you don’t get stuck for too long

Page 19: 61A Lecture 1 - wla.berkeley.edu

Soda Hall

The Course Staff

3

40+ Teaching Assistants (GSIs/UGSIs) run labs, discussions, and office hours

30+ Tutors are your personal programming mentors

150+ Lab Assistants ensure that you don’t get stuck for too long

Page 20: 61A Lecture 1 - wla.berkeley.edu

Soda Hall

The Course Staff

3

40+ Teaching Assistants (GSIs/UGSIs) run labs, discussions, and office hours

30+ Tutors are your personal programming mentors

150+ Lab Assistants ensure that you don’t get stuck for too long

Page 21: 61A Lecture 1 - wla.berkeley.edu

Soda Hall Evans Hall

The Course Staff

3

40+ Teaching Assistants (GSIs/UGSIs) run labs, discussions, and office hours

30+ Tutors are your personal programming mentors

150+ Lab Assistants ensure that you don’t get stuck for too long

Page 22: 61A Lecture 1 - wla.berkeley.edu

Soda Hall Evans Hall

The Course Staff

3

40+ Teaching Assistants (GSIs/UGSIs) run labs, discussions, and office hours

30+ Tutors are your personal programming mentors

150+ Lab Assistants ensure that you don’t get stuck for too long

Page 23: 61A Lecture 1 - wla.berkeley.edu

Parts of the Course

4

Page 24: 61A Lecture 1 - wla.berkeley.edu

Parts of the Course

Lecture: Videos posted to cs61a.org before each live lecture

4

Page 25: 61A Lecture 1 - wla.berkeley.edu

Parts of the Course

Lecture: Videos posted to cs61a.org before each live lecture

Lab: The most important events in this course

4

Page 26: 61A Lecture 1 - wla.berkeley.edu

Parts of the Course

Lecture: Videos posted to cs61a.org before each live lecture

Lab: The most important events in this course

Discussion: Also the most important events in this course

4

Page 27: 61A Lecture 1 - wla.berkeley.edu

Parts of the Course

Lecture: Videos posted to cs61a.org before each live lecture

Lab: The most important events in this course

Discussion: Also the most important events in this course

Office Hours: Also the most important events in this course [11-5 M-Th & 11-1 Friday]

4

Page 28: 61A Lecture 1 - wla.berkeley.edu

Parts of the Course

Lecture: Videos posted to cs61a.org before each live lecture

Lab: The most important events in this course

Discussion: Also the most important events in this course

Office Hours: Also the most important events in this course [11-5 M-Th & 11-1 Friday]

Online textbook: http://composingprograms.com

4

Page 29: 61A Lecture 1 - wla.berkeley.edu

Parts of the Course

Lecture: Videos posted to cs61a.org before each live lecture

Lab: The most important events in this course

Discussion: Also the most important events in this course

Office Hours: Also the most important events in this course [11-5 M-Th & 11-1 Friday]

Online textbook: http://composingprograms.com

Weekly homework assignments, three exams, quizzes, & four programming projects

4

Page 30: 61A Lecture 1 - wla.berkeley.edu

Parts of the Course

Lecture: Videos posted to cs61a.org before each live lecture

Lab: The most important events in this course

Discussion: Also the most important events in this course

Office Hours: Also the most important events in this course [11-5 M-Th & 11-1 Friday]

Online textbook: http://composingprograms.com

Weekly homework assignments, three exams, quizzes, & four programming projects

Lots of special events

4

Page 31: 61A Lecture 1 - wla.berkeley.edu

An Introduction to Computer Science

Page 32: 61A Lecture 1 - wla.berkeley.edu

What is Computer Science?

6

Page 33: 61A Lecture 1 - wla.berkeley.edu

What is Computer Science?

6

The study of

Page 34: 61A Lecture 1 - wla.berkeley.edu

What is Computer Science?

6

What problems can be solved using computation,The study of

Page 35: 61A Lecture 1 - wla.berkeley.edu

What is Computer Science?

6

What problems can be solved using computation,How to solve those problems, andThe study of

Page 36: 61A Lecture 1 - wla.berkeley.edu

What is Computer Science?

6

What problems can be solved using computation,How to solve those problems, andWhat techniques lead to effective solutions

The study of

Page 37: 61A Lecture 1 - wla.berkeley.edu

What is Computer Science?

Systems

6

What problems can be solved using computation,How to solve those problems, andWhat techniques lead to effective solutions

The study of

Page 38: 61A Lecture 1 - wla.berkeley.edu

What is Computer Science?

Systems

Artificial Intelligence

6

What problems can be solved using computation,How to solve those problems, andWhat techniques lead to effective solutions

The study of

Page 39: 61A Lecture 1 - wla.berkeley.edu

What is Computer Science?

Systems

Artificial Intelligence

Graphics

6

What problems can be solved using computation,How to solve those problems, andWhat techniques lead to effective solutions

The study of

Page 40: 61A Lecture 1 - wla.berkeley.edu

What is Computer Science?

Systems

Artificial Intelligence

Graphics

Security

6

What problems can be solved using computation,How to solve those problems, andWhat techniques lead to effective solutions

The study of

Page 41: 61A Lecture 1 - wla.berkeley.edu

What is Computer Science?

Systems

Artificial Intelligence

Graphics

Security

Networking

Programming Languages

Theory

Scientific Computing

...

6

What problems can be solved using computation,How to solve those problems, andWhat techniques lead to effective solutions

The study of

Page 42: 61A Lecture 1 - wla.berkeley.edu

What is Computer Science?

Systems

Artificial Intelligence

Graphics

Security

Networking

Programming Languages

Theory

Scientific Computing

...

6

What problems can be solved using computation,How to solve those problems, andWhat techniques lead to effective solutions

The study of

Page 43: 61A Lecture 1 - wla.berkeley.edu

What is Computer Science?

Systems

Artificial Intelligence

Graphics

Security

Networking

Programming Languages

Theory

Scientific Computing

...

6

Decision Making

What problems can be solved using computation,How to solve those problems, andWhat techniques lead to effective solutions

The study of

Page 44: 61A Lecture 1 - wla.berkeley.edu

What is Computer Science?

Systems

Artificial Intelligence

Graphics

Security

Networking

Programming Languages

Theory

Scientific Computing

...

6

Decision Making

Robotics

What problems can be solved using computation,How to solve those problems, andWhat techniques lead to effective solutions

The study of

Page 45: 61A Lecture 1 - wla.berkeley.edu

What is Computer Science?

Systems

Artificial Intelligence

Graphics

Security

Networking

Programming Languages

Theory

Scientific Computing

...

6

Decision Making

Robotics

Natural Language Processing

What problems can be solved using computation,How to solve those problems, andWhat techniques lead to effective solutions

The study of

Page 46: 61A Lecture 1 - wla.berkeley.edu

What is Computer Science?

Systems

Artificial Intelligence

Graphics

Security

Networking

Programming Languages

Theory

Scientific Computing

...

6

Decision Making

Robotics

Natural Language Processing

...

What problems can be solved using computation,How to solve those problems, andWhat techniques lead to effective solutions

The study of

Page 47: 61A Lecture 1 - wla.berkeley.edu

What is Computer Science?

Systems

Artificial Intelligence

Graphics

Security

Networking

Programming Languages

Theory

Scientific Computing

...

6

Decision Making

Robotics

Natural Language Processing

...

What problems can be solved using computation,How to solve those problems, andWhat techniques lead to effective solutions

The study of

Page 48: 61A Lecture 1 - wla.berkeley.edu

What is Computer Science?

Systems

Artificial Intelligence

Graphics

Security

Networking

Programming Languages

Theory

Scientific Computing

...

6

Decision Making

Robotics

Natural Language Processing

...

What problems can be solved using computation,How to solve those problems, andWhat techniques lead to effective solutions

The study of

Translation

Page 49: 61A Lecture 1 - wla.berkeley.edu

What is Computer Science?

Systems

Artificial Intelligence

Graphics

Security

Networking

Programming Languages

Theory

Scientific Computing

...

6

Decision Making

Robotics

Natural Language Processing

...

What problems can be solved using computation,How to solve those problems, andWhat techniques lead to effective solutions

The study of

Translation

Answering Questions

Page 50: 61A Lecture 1 - wla.berkeley.edu

What is Computer Science?

Systems

Artificial Intelligence

Graphics

Security

Networking

Programming Languages

Theory

Scientific Computing

...

6

Decision Making

Robotics

Natural Language Processing

...

What problems can be solved using computation,How to solve those problems, andWhat techniques lead to effective solutions

The study of

Translation

Answering Questions

...

Page 51: 61A Lecture 1 - wla.berkeley.edu

What is Computer Science?

Systems

Artificial Intelligence

Graphics

Security

Networking

Programming Languages

Theory

Scientific Computing

...

6

Decision Making

Robotics

Natural Language Processing

...

What problems can be solved using computation,How to solve those problems, andWhat techniques lead to effective solutions

The study of

Translation

Answering Questions

...

Page 52: 61A Lecture 1 - wla.berkeley.edu

What is This Course About?

7

Page 53: 61A Lecture 1 - wla.berkeley.edu

What is This Course About?

• A course about managing complexity

7

Page 54: 61A Lecture 1 - wla.berkeley.edu

What is This Course About?

• A course about managing complexity

§Mastering abstraction

7

Page 55: 61A Lecture 1 - wla.berkeley.edu

What is This Course About?

• A course about managing complexity

§Mastering abstraction

§Using programming paradigms

7

Page 56: 61A Lecture 1 - wla.berkeley.edu

What is This Course About?

• A course about managing complexity

§Mastering abstraction

§Using programming paradigms

§Completing big projects

7

Page 57: 61A Lecture 1 - wla.berkeley.edu

What is This Course About?

• A course about managing complexity

§Mastering abstraction

§Using programming paradigms

§Completing big projects

7

Page 58: 61A Lecture 1 - wla.berkeley.edu

What is This Course About?

• A course about managing complexity

§Mastering abstraction

§Using programming paradigms

§Completing big projects

• An introduction to Python

7

Page 59: 61A Lecture 1 - wla.berkeley.edu

What is This Course About?

• A course about managing complexity

§Mastering abstraction

§Using programming paradigms

§Completing big projects

• An introduction to Python

§Full understanding of fundamentals

7

Page 60: 61A Lecture 1 - wla.berkeley.edu

What is This Course About?

• A course about managing complexity

§Mastering abstraction

§Using programming paradigms

§Completing big projects

• An introduction to Python

§Full understanding of fundamentals

§Learning through implementation

7

Page 61: 61A Lecture 1 - wla.berkeley.edu

What is This Course About?

• A course about managing complexity

§Mastering abstraction

§Using programming paradigms

§Completing big projects

• An introduction to Python

§Full understanding of fundamentals

§Learning through implementation

§How computers interpret programming languages

7

Page 62: 61A Lecture 1 - wla.berkeley.edu

What is This Course About?

• A course about managing complexity

§Mastering abstraction

§Using programming paradigms

§Completing big projects

• An introduction to Python

§Full understanding of fundamentals

§Learning through implementation

§How computers interpret programming languages

• A challenging course that will demand a lot of you

7

Page 63: 61A Lecture 1 - wla.berkeley.edu

Other Courses

Page 64: 61A Lecture 1 - wla.berkeley.edu

CS 61AS: Self-Paced 61A

9

Page 65: 61A Lecture 1 - wla.berkeley.edu

CS 61AS: Self-Paced 61A

You choose the pace! The course can be completed over two semesters

9

Page 66: 61A Lecture 1 - wla.berkeley.edu

CS 61AS: Self-Paced 61A

You choose the pace! The course can be completed over two semesters

Extra content for people without prior programming experience

9

Page 67: 61A Lecture 1 - wla.berkeley.edu

CS 61AS: Self-Paced 61A

You choose the pace! The course can be completed over two semesters

Extra content for people without prior programming experience

A brilliant textbook, interesting projects, a great language, and a dedicated course staff

9

Page 68: 61A Lecture 1 - wla.berkeley.edu

CS 61AS: Self-Paced 61A

You choose the pace! The course can be completed over two semesters

Extra content for people without prior programming experience

A brilliant textbook, interesting projects, a great language, and a dedicated course staff

More info: cs61as.org

9

Page 69: 61A Lecture 1 - wla.berkeley.edu

CS 10: The Beauty and Joy of Computing

10

Page 70: 61A Lecture 1 - wla.berkeley.edu

CS 10: The Beauty and Joy of Computing

10

Page 71: 61A Lecture 1 - wla.berkeley.edu

CS 10: The Beauty and Joy of Computing

10

Page 72: 61A Lecture 1 - wla.berkeley.edu

CS 10: The Beauty and Joy of Computing

Designed for students without prior experience

10

Page 73: 61A Lecture 1 - wla.berkeley.edu

CS 10: The Beauty and Joy of Computing

Designed for students without prior experience

A programming environment created by Berkeley, now used in courses around the world and online

10

Page 74: 61A Lecture 1 - wla.berkeley.edu

CS 10: The Beauty and Joy of Computing

Designed for students without prior experience

A programming environment created by Berkeley, now used in courses around the world and online

10

Page 75: 61A Lecture 1 - wla.berkeley.edu

CS 10: The Beauty and Joy of Computing

Designed for students without prior experience

A programming environment created by Berkeley, now used in courses around the world and online

10

Page 76: 61A Lecture 1 - wla.berkeley.edu

CS 10: The Beauty and Joy of Computing

Designed for students without prior experience

A programming environment created by Berkeley, now used in courses around the world and online

An introduction to fundamentals (& Python) that sets students up for success in CS 61A

10

Page 77: 61A Lecture 1 - wla.berkeley.edu

CS 10: The Beauty and Joy of Computing

Designed for students without prior experience

A programming environment created by Berkeley, now used in courses around the world and online

An introduction to fundamentals (& Python) that sets students up for success in CS 61A

More info: cs10.org

10

Page 78: 61A Lecture 1 - wla.berkeley.edu

Data Science 8: Foundations of Data Science

11

Page 79: 61A Lecture 1 - wla.berkeley.edu

Data Science 8: Foundations of Data Science

Fundamentals of computing and inference applied to real-world data

11

Page 80: 61A Lecture 1 - wla.berkeley.edu

Data Science 8: Foundations of Data Science

Fundamentals of computing and inference applied to real-world data

11

Page 81: 61A Lecture 1 - wla.berkeley.edu

Data Science 8: Foundations of Data Science

Fundamentals of computing and inference applied to real-world data

Great programming practice for CS 61A

11

Page 82: 61A Lecture 1 - wla.berkeley.edu

Data Science 8: Foundations of Data Science

Fundamentals of computing and inference applied to real-world data

Great programming practice for CS 61A

In Fall 2015, piloted as Stat 94 (CCN: 87470)

11

Page 83: 61A Lecture 1 - wla.berkeley.edu

Data Science 8: Foundations of Data Science

Fundamentals of computing and inference applied to real-world data

Great programming practice for CS 61A

In Fall 2015, piloted as Stat 94 (CCN: 87470)

More info: data8.org & databears.berkeley.edu

11

Page 84: 61A Lecture 1 - wla.berkeley.edu

Course Policies

Page 85: 61A Lecture 1 - wla.berkeley.edu

Course Policies

13

Page 86: 61A Lecture 1 - wla.berkeley.edu

Course Policies

13

Learning

Page 87: 61A Lecture 1 - wla.berkeley.edu

Course Policies

13

Learning

Community

Page 88: 61A Lecture 1 - wla.berkeley.edu

Course Policies

13

Learning

Course Staff

Community

Page 89: 61A Lecture 1 - wla.berkeley.edu

Course Policies

13

Learning

Course Staff

Details...

http://cs61a.org/about.html

Community

Page 90: 61A Lecture 1 - wla.berkeley.edu

Collaboration

14

Page 91: 61A Lecture 1 - wla.berkeley.edu

Collaboration

14

Asking questions is highly encouraged

Page 92: 61A Lecture 1 - wla.berkeley.edu

Collaboration

• Discuss everything with each other; learn from your fellow students!

14

Asking questions is highly encouraged

Page 93: 61A Lecture 1 - wla.berkeley.edu

Collaboration

• Discuss everything with each other; learn from your fellow students!

• Homework can be completed with a partner

14

Asking questions is highly encouraged

Page 94: 61A Lecture 1 - wla.berkeley.edu

Collaboration

• Discuss everything with each other; learn from your fellow students!

• Homework can be completed with a partner

• Projects should be completed with a partner

14

Asking questions is highly encouraged

Page 95: 61A Lecture 1 - wla.berkeley.edu

Collaboration

• Discuss everything with each other; learn from your fellow students!

• Homework can be completed with a partner

• Projects should be completed with a partner

• Choose a partner from your discussion section

14

Asking questions is highly encouraged

Page 96: 61A Lecture 1 - wla.berkeley.edu

Collaboration

• Discuss everything with each other; learn from your fellow students!

• Homework can be completed with a partner

• Projects should be completed with a partner

• Choose a partner from your discussion section

14

The limits of collaboration

Asking questions is highly encouraged

Page 97: 61A Lecture 1 - wla.berkeley.edu

Collaboration

• Discuss everything with each other; learn from your fellow students!

• Homework can be completed with a partner

• Projects should be completed with a partner

• Choose a partner from your discussion section

14

• One simple rule: Don’t share your code, except with your partner

The limits of collaboration

Asking questions is highly encouraged

Page 98: 61A Lecture 1 - wla.berkeley.edu

Collaboration

• Discuss everything with each other; learn from your fellow students!

• Homework can be completed with a partner

• Projects should be completed with a partner

• Choose a partner from your discussion section

14

• One simple rule: Don’t share your code, except with your partner

• Copying project solutions causes people to fail this course

The limits of collaboration

Asking questions is highly encouraged

Page 99: 61A Lecture 1 - wla.berkeley.edu

Collaboration

• Discuss everything with each other; learn from your fellow students!

• Homework can be completed with a partner

• Projects should be completed with a partner

• Choose a partner from your discussion section

14

• One simple rule: Don’t share your code, except with your partner

• Copying project solutions causes people to fail this course

• We really do catch people who violate the rules, because...

The limits of collaboration

Asking questions is highly encouraged

Page 100: 61A Lecture 1 - wla.berkeley.edu

Collaboration

• Discuss everything with each other; learn from your fellow students!

• Homework can be completed with a partner

• Projects should be completed with a partner

• Choose a partner from your discussion section

14

• One simple rule: Don’t share your code, except with your partner

• Copying project solutions causes people to fail this course

• We really do catch people who violate the rules, because...

• We also know how to search the web for solutions

The limits of collaboration

Asking questions is highly encouraged

Page 101: 61A Lecture 1 - wla.berkeley.edu

Collaboration

• Discuss everything with each other; learn from your fellow students!

• Homework can be completed with a partner

• Projects should be completed with a partner

• Choose a partner from your discussion section

14

• One simple rule: Don’t share your code, except with your partner

• Copying project solutions causes people to fail this course

• We really do catch people who violate the rules, because...

• We also know how to search the web for solutions

• We use computers to check your work

The limits of collaboration

Asking questions is highly encouraged

Page 102: 61A Lecture 1 - wla.berkeley.edu

Collaboration

• Discuss everything with each other; learn from your fellow students!

• Homework can be completed with a partner

• Projects should be completed with a partner

• Choose a partner from your discussion section

14

• One simple rule: Don’t share your code, except with your partner

• Copying project solutions causes people to fail this course

• We really do catch people who violate the rules, because...

• We also know how to search the web for solutions

• We use computers to check your work

The limits of collaboration

Asking questions is highly encouraged

Build good habits now

Page 103: 61A Lecture 1 - wla.berkeley.edu

Expressions

Page 104: 61A Lecture 1 - wla.berkeley.edu

Types of expressions

16

Page 105: 61A Lecture 1 - wla.berkeley.edu

Types of expressions

16

An expression describes a computation and evaluates to a value

Page 106: 61A Lecture 1 - wla.berkeley.edu

18 + 69

Types of expressions

16

An expression describes a computation and evaluates to a value

Page 107: 61A Lecture 1 - wla.berkeley.edu

18 + 696

23

Types of expressions

16

An expression describes a computation and evaluates to a value

Page 108: 61A Lecture 1 - wla.berkeley.edu

18 + 696

23

p3493161

Types of expressions

16

An expression describes a computation and evaluates to a value

Page 109: 61A Lecture 1 - wla.berkeley.edu

18 + 696

23

p3493161

sin⇡

Types of expressions

16

An expression describes a computation and evaluates to a value

Page 110: 61A Lecture 1 - wla.berkeley.edu

18 + 696

23

p3493161

sin⇡

|� 1869|

Types of expressions

16

An expression describes a computation and evaluates to a value

Page 111: 61A Lecture 1 - wla.berkeley.edu

18 + 696

23

p3493161

sin⇡

100X

i=1

i

|� 1869|

Types of expressions

16

An expression describes a computation and evaluates to a value

Page 112: 61A Lecture 1 - wla.berkeley.edu

18 + 696

23

p3493161

sin⇡

100X

i=1

i

|� 1869|

✓69

18

Types of expressions

16

An expression describes a computation and evaluates to a value

Page 113: 61A Lecture 1 - wla.berkeley.edu

18 + 696

23

p3493161

sin⇡

f(x)100X

i=1

i

|� 1869|

✓69

18

Types of expressions

16

An expression describes a computation and evaluates to a value

Page 114: 61A Lecture 1 - wla.berkeley.edu

18 + 696

23

p3493161

sin⇡

f(x)100X

i=1

i

|� 1869|

✓69

18

2100

Types of expressions

16

An expression describes a computation and evaluates to a value

Page 115: 61A Lecture 1 - wla.berkeley.edu

18 + 696

23

p3493161

sin⇡

f(x)100X

i=1

i

|� 1869|

✓69

18

2100

log2 1024

Types of expressions

16

An expression describes a computation and evaluates to a value

Page 116: 61A Lecture 1 - wla.berkeley.edu

18 + 696

23

p3493161

sin⇡

f(x)100X

i=1

i

|� 1869|

✓69

18

2100

log2 1024

7 mod 2

Types of expressions

16

An expression describes a computation and evaluates to a value

Page 117: 61A Lecture 1 - wla.berkeley.edu

18 + 696

23

p3493161

sin⇡

f(x)100X

i=1

i

|� 1869|

✓69

18

2100

log2 1024

7 mod 2

limx!1

1

x

Types of expressions

16

An expression describes a computation and evaluates to a value

Page 118: 61A Lecture 1 - wla.berkeley.edu

18 + 696

23

p3493161

sin⇡

f(x)100X

i=1

i

|� 1869|

✓69

18

2100

log2 1024

7 mod 2

limx!1

1

x

Types of expressions

16

An expression describes a computation and evaluates to a value

Page 119: 61A Lecture 1 - wla.berkeley.edu

Call Expressions in Python

All expressions can use function call notation

(Demo)

17

Page 120: 61A Lecture 1 - wla.berkeley.edu

Anatomy of a Call Expression

18

Page 121: 61A Lecture 1 - wla.berkeley.edu

Anatomy of a Call Expression

18

add ( 2 , 3 )

Page 122: 61A Lecture 1 - wla.berkeley.edu

Anatomy of a Call Expression

18

add ( 2 , 3 )

Page 123: 61A Lecture 1 - wla.berkeley.edu

Anatomy of a Call Expression

18

add ( 2 , 3 )

Operator

Page 124: 61A Lecture 1 - wla.berkeley.edu

Anatomy of a Call Expression

18

add ( 2 , 3 )

Operator Operand Operand

Page 125: 61A Lecture 1 - wla.berkeley.edu

Anatomy of a Call Expression

18

add ( 2 , 3 )

Operator Operand Operand

Operators and operands are also expressions

Page 126: 61A Lecture 1 - wla.berkeley.edu

Anatomy of a Call Expression

18

add ( 2 , 3 )

Operator Operand Operand

Operators and operands are also expressions

So they evaluate to values

Page 127: 61A Lecture 1 - wla.berkeley.edu

Anatomy of a Call Expression

18

Evaluation procedure for call expressions:

add ( 2 , 3 )

Operator Operand Operand

Operators and operands are also expressions

So they evaluate to values

Page 128: 61A Lecture 1 - wla.berkeley.edu

Anatomy of a Call Expression

18

Evaluation procedure for call expressions:

add ( 2 , 3 )

Operator Operand Operand

Operators and operands are also expressions

1. Evaluate the operator and then the operand subexpressions

So they evaluate to values

Page 129: 61A Lecture 1 - wla.berkeley.edu

Anatomy of a Call Expression

18

Evaluation procedure for call expressions:

add ( 2 , 3 )

Operator Operand Operand

Operators and operands are also expressions

1. Evaluate the operator and then the 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

Page 130: 61A Lecture 1 - wla.berkeley.edu

mul(add(2, mul(4, 6)), add(3, 5))

Evaluating Nested Expressions

19

Page 131: 61A Lecture 1 - wla.berkeley.edu

mul(add(2, mul(4, 6)), add(3, 5))

Evaluating Nested Expressions

19

Page 132: 61A Lecture 1 - wla.berkeley.edu

mul(add(2, mul(4, 6)), add(3, 5))

Evaluating Nested Expressions

19

mul

Page 133: 61A Lecture 1 - wla.berkeley.edu

mul(add(2, mul(4, 6)), add(3, 5))

add(2, mul(4, 6))

Evaluating Nested Expressions

19

mul

Page 134: 61A Lecture 1 - wla.berkeley.edu

mul(add(2, mul(4, 6)), add(3, 5))

add(2, mul(4, 6))

Evaluating Nested Expressions

19

mul

add

Page 135: 61A Lecture 1 - wla.berkeley.edu

mul(add(2, mul(4, 6)), add(3, 5))

add(2, mul(4, 6))

Evaluating Nested Expressions

19

mul

add 2

Page 136: 61A Lecture 1 - wla.berkeley.edu

mul(add(2, mul(4, 6)), add(3, 5))

add(2, mul(4, 6))

Evaluating Nested Expressions

19

mul

add 2

mul(4, 6)

Page 137: 61A Lecture 1 - wla.berkeley.edu

mul(add(2, mul(4, 6)), add(3, 5))

add(2, mul(4, 6))

Evaluating Nested Expressions

19

mul

add 2

mul(4, 6)

mul 4 6

Page 138: 61A Lecture 1 - wla.berkeley.edu

mul(add(2, mul(4, 6)), add(3, 5))

add(2, mul(4, 6))

Evaluating Nested Expressions

19

mul

add 2

mul(4, 6)

mul 4 6

24

Page 139: 61A Lecture 1 - wla.berkeley.edu

mul(add(2, mul(4, 6)), add(3, 5))

add(2, mul(4, 6))

Evaluating Nested Expressions

19

26mul

add 2

mul(4, 6)

mul 4 6

24

Page 140: 61A Lecture 1 - wla.berkeley.edu

mul(add(2, mul(4, 6)), add(3, 5))

add(2, mul(4, 6))

Evaluating Nested Expressions

19

26mul

add 2

mul(4, 6)

mul 4 6

24

add(3, 5)

Page 141: 61A Lecture 1 - wla.berkeley.edu

mul(add(2, mul(4, 6)), add(3, 5))

add(2, mul(4, 6))

Evaluating Nested Expressions

19

26mul

add 2

mul(4, 6)

mul 4 6

24

add(3, 5)

add 3 5

Page 142: 61A Lecture 1 - wla.berkeley.edu

mul(add(2, mul(4, 6)), add(3, 5))

add(2, mul(4, 6))

Evaluating Nested Expressions

19

26mul

add 2

mul(4, 6)

mul 4 6

24

add(3, 5)

add 3 5

8

Page 143: 61A Lecture 1 - wla.berkeley.edu

208mul(add(2, mul(4, 6)), add(3, 5))

add(2, mul(4, 6))

Evaluating Nested Expressions

19

26mul

add 2

mul(4, 6)

mul 4 6

24

add(3, 5)

add 3 5

8

Page 144: 61A Lecture 1 - wla.berkeley.edu

208mul(add(2, mul(4, 6)), add(3, 5))

add(2, mul(4, 6))26mul

add 2

mul(4, 6)

mul 4 6

24

add(3, 5)

add 3 5

8

Evaluating Nested Expressions

20

Page 145: 61A Lecture 1 - wla.berkeley.edu

208mul(add(2, mul(4, 6)), add(3, 5))

add(2, mul(4, 6))26mul

add 2

mul(4, 6)

mul 4 6

24

add(3, 5)

add 3 5

8

Evaluating Nested Expressions

20

Expression tree

Page 146: 61A Lecture 1 - wla.berkeley.edu

208mul(add(2, mul(4, 6)), add(3, 5))

add(2, mul(4, 6))26mul

add 2

mul(4, 6)

mul 4 6

24

add(3, 5)

add 3 5

8

Evaluating Nested Expressions

20

Expression tree

Operand subexpression

Page 147: 61A Lecture 1 - wla.berkeley.edu

208mul(add(2, mul(4, 6)), add(3, 5))

add(2, mul(4, 6))26mul

add 2

mul(4, 6)

mul 4 6

24

add(3, 5)

add 3 5

8

Evaluating Nested Expressions

20

Expression tree

Operand subexpression

Value of subexpression

Page 148: 61A Lecture 1 - wla.berkeley.edu

208mul(add(2, mul(4, 6)), add(3, 5))

add(2, mul(4, 6))26mul

add 2

mul(4, 6)

mul 4 6

24

add(3, 5)

add 3 5

8

Evaluating Nested Expressions

20

Expression tree

Operand subexpression

1st argument to mulValue of subexpression

Page 149: 61A Lecture 1 - wla.berkeley.edu

208mul(add(2, mul(4, 6)), add(3, 5))

add(2, mul(4, 6))26mul

add 2

mul(4, 6)

mul 4 6

24

add(3, 5)

add 3 5

8

Evaluating Nested Expressions

20

Expression tree

Operand subexpression

1st argument to mul

Value of the whole expression

Value of subexpression

Page 150: 61A Lecture 1 - wla.berkeley.edu

Functions, Objects, and Interpreters

(Demo)