CS61A Lecture 1 Amir Kamil UC Berkeley January 23, 2013 Welcome to - - PowerPoint PPT Presentation

cs61a lecture 1
SMART_READER_LITE
LIVE PREVIEW

CS61A Lecture 1 Amir Kamil UC Berkeley January 23, 2013 Welcome to - - PowerPoint PPT Presentation

CS61A Lecture 1 Amir Kamil UC Berkeley January 23, 2013 Welcome to CS61A! The Course Staff Ive been at Berkeley a long time, and took CS61A a while back. Read the course info to find out when! TAs essentially run the course Readers, lab


slide-1
SLIDE 1

CS61A Lecture 1

Amir Kamil UC Berkeley January 23, 2013

slide-2
SLIDE 2

Welcome to CS61A!

slide-3
SLIDE 3

The Course Staff

I’ve been at Berkeley a long time, and took CS61A a while back. Read the course info to find out when! TAs essentially run the course Readers, lab assistants help you learn the material

slide-4
SLIDE 4

Some mythical notion of “hacking?”

What is Computer Science?

slide-5
SLIDE 5

Some mythical notion of “hacking?”

What is Computer Science?

slide-6
SLIDE 6

Some mythical notion of “hacking?”

What is Computer Science?

slide-7
SLIDE 7

Some mythical notion of “hacking?”

What is Computer Science?

slide-8
SLIDE 8

Some mythical notion of “hacking?”

What is Computer Science?

slide-9
SLIDE 9

“Computer science deals with the theoretical foundations of information and computation, together with practical techniques for the implementation and application of these foundations” ‐ Wikipedia

What is Computer Science?

slide-10
SLIDE 10

        

Computer Science is Everywhere

         

slide-11
SLIDE 11

Phones Cars Politics Games Movies Music Sports Anything connected to the Internet …

Computer Science is Everywhere

         

slide-12
SLIDE 12

Phones Cars Politics Games Movies Music Sports Anything connected to the Internet …

Computer Science is Everywhere

Systems Programming Languages Graphics Artificial Intelligence Databases Theory Security Parallel Computing Quantum Computing …

slide-13
SLIDE 13

 An introduction to the “big ideas” in

programming

 Functions, data structures, recursion, interpretation,

parallelism, …

 We use Python as our programming vehicle in

this course, but the ideas apply to any language

 General focus: how to manage complexity

 Primary tool is abstraction

What is CS61A?

slide-14
SLIDE 14

  

What is Abstraction?

slide-15
SLIDE 15

 Abstraction is exposing the what of something

while hiding the how

 

What is Abstraction?

slide-16
SLIDE 16

 Abstraction is exposing the what of something

while hiding the how

 Many layers of abstraction in a typical system 

What is Abstraction?

slide-17
SLIDE 17

 Abstraction is exposing the what of something

while hiding the how

 Many layers of abstraction in a typical system 

What is Abstraction?

Application Libraries (Graphics, Physics) Operating System Hardware (CPU, RAM, etc.) Logic Gates

slide-18
SLIDE 18

 Abstraction is exposing the what of something

while hiding the how

 Many layers of abstraction in a typical system  This course will teach you how to build and use

abstractions

What is Abstraction?

Application Libraries (Graphics, Physics) Operating System Hardware (CPU, RAM, etc.) Logic Gates

slide-19
SLIDE 19

The purpose of this course is to help you learn The staff is here to make you successful All the details are on the website:

http://inst.eecs.berkeley.edu/~cs61a/sp13/about.html Ask questions on Piazza https://piazza.com/class#spring2013/cs61a

Course Policies

slide-20
SLIDE 20

 Readings cover the material; read before lecture  Lectures summarize material, present in new way  Labs introduce new topics or practical skills  Discussions provide practice on the material  Homeworks are deeper exercises that require

more thought than labs

 Graded on effort, generally due Wed. at 11:59pm

 Projects are larger assignments designed to teach

you how use and combine ideas from the course in interesting ways

Course Organization

slide-21
SLIDE 21

 Discuss everything with each other  EPA: Effort, participation, and altruism  Homework may be completed with a partner  Projects should be completed with a partner  Find a project partner in your section!

The limits of collaboration

 Never share code  Copying projects is a serious offense, and we will

find out if you do

Collaboration

slide-22
SLIDE 22

 Both lectures are the same; you may attend

either, space permitting

 Lectures are webcast; link will be online soon  Midterms are on 2/13 and 3/21  Final exam is 5/14 for both lectures

 Let us know ASAP if you have a conflict with any exam

 See the Course Info for enrollment issues  If you are on the waitlist, still complete

assignments!

FAQ

slide-23
SLIDE 23

 Make sure you have an account form and register

 You will need one to submit homework and projects  Get one in discussion or office hours if you don’t have one

 Office hours start tomorrow

 See website schedule

 Study session Wed. 9:30‐11:30am in the Woz

 Mega office hours with multiple staff members present  Opportunities for collaboration and EPA

 Homework 0 due Fri. at 7pm  Homework 1 due Wed. at 11:59pm

Announcements

slide-24
SLIDE 24

Data: the things that programs fiddle with

 

Data, Functions, and Interpreters

slide-25
SLIDE 25

Data: the things that programs fiddle with

 

Data, Functions, and Interpreters

2 “Super Bowl XLVII” Mike Krzyzewski Shakespeare’s 37 plays

slide-26
SLIDE 26

Data: the things that programs fiddle with Functions: rules for manipulating data

Data, Functions, and Interpreters

2 “Super Bowl XLVII” Mike Krzyzewski Shakespeare’s 37 plays

slide-27
SLIDE 27

Data: the things that programs fiddle with Functions: rules for manipulating data

Data, Functions, and Interpreters

2 “Super Bowl XLVII” Mike Krzyzewski Shakespeare’s 37 plays Add up numbers Pronounce someone’s name Count the words in a line of text

slide-28
SLIDE 28

Data: the things that programs fiddle with Functions: rules for manipulating data Interpreter: an implementation of the procedure for evaluation

Data, Functions, and Interpreters

2 “Super Bowl XLVII” Mike Krzyzewski Shakespeare’s 37 plays Add up numbers Pronounce someone’s name Count the words in a line of text

slide-29
SLIDE 29

 Primitive values are the simplest type of data

   

  

Primitive Values and Expressions

slide-30
SLIDE 30

 Primitive values are the simplest type of data

Integers: 2, 3, 2013, ‐837592010 Floating point (decimal) values: ‐4.5, 98.6 Strings: “It was a dark and stormy night” Booleans: True, False

  

Primitive Values and Expressions

slide-31
SLIDE 31

 Primitive values are the simplest type of data

Integers: 2, 3, 2013, ‐837592010 Floating point (decimal) values: ‐4.5, 98.6 Strings: “It was a dark and stormy night” Booleans: True, False

 An expression is something that produces a value

  

Primitive Values and Expressions

slide-32
SLIDE 32

 Primitive values are the simplest type of data

Integers: 2, 3, 2013, ‐837592010 Floating point (decimal) values: ‐4.5, 98.6 Strings: “It was a dark and stormy night” Booleans: True, False

 An expression is something that produces a value

2 + 3 sqrt(2401) abs(‐128 + 42 * 3)

Primitive Values and Expressions

slide-33
SLIDE 33

 All expressions can use function call notation

  

 

Call Expressions in Python

slide-34
SLIDE 34

 All expressions can use function call notation

2 + 3 add(2, 3) sqrt(2401) sqrt(2401) abs(‐128 + 42 * 3) abs(add(‐128, mul(42, 3)))

 

Call Expressions in Python

slide-35
SLIDE 35

 All expressions can use function call notation

2 + 3 add(2, 3) sqrt(2401) sqrt(2401) abs(‐128 + 42 * 3) abs(add(‐128, mul(42, 3)))

 Infix operator notation is syntactic sugar for

function calls

Call Expressions in Python

slide-36
SLIDE 36

 All expressions can use function call notation

2 + 3 add(2, 3) sqrt(2401) sqrt(2401) abs(‐128 + 42 * 3) abs(add(‐128, mul(42, 3)))

 Infix operator notation is syntactic sugar for

function calls

 Mathematical operators obey usual precedence

rules

Call Expressions in Python

slide-37
SLIDE 37

Anatomy of a Call Expression

add ( 2 , 3 ) Operator Operand 0 Operand 1

slide-38
SLIDE 38

Operators and operands are expressions, so they evaluate to values

Anatomy of a Call Expression

add ( 2 , 3 ) Operator Operand 0 Operand 1

slide-39
SLIDE 39

Operators and operands are expressions, so they evaluate to values

Evaluation procedure for call expressions:

Anatomy of a Call Expression

add ( 2 , 3 ) Operator Operand 0 Operand 1

slide-40
SLIDE 40

Operators and operands are expressions, so they evaluate to values

Evaluation procedure for call expressions:

1.

Evaluate the operator and operand subexpressions in order from left to right.

Anatomy of a Call Expression

add ( 2 , 3 ) Operator Operand 0 Operand 1

slide-41
SLIDE 41

Operators and operands are expressions, so they evaluate to values

Evaluation procedure for call expressions:

1.

Evaluate the operator and operand subexpressions in order from left to right.

2.

Apply the function that is the value of the operator subexpression to the arguments that are the values of the

  • perand subexpressions

Anatomy of a Call Expression

add ( 2 , 3 ) Operator Operand 0 Operand 1

slide-42
SLIDE 42

Evaluating Nested Expressions

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

slide-43
SLIDE 43

Evaluating Nested Expressions

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

slide-44
SLIDE 44

Evaluating Nested Expressions

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

slide-45
SLIDE 45

Evaluating Nested Expressions

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

slide-46
SLIDE 46

Evaluating Nested Expressions

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

slide-47
SLIDE 47

Evaluating Nested Expressions

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

slide-48
SLIDE 48

Evaluating Nested Expressions

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

slide-49
SLIDE 49

Evaluating Nested Expressions

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

slide-50
SLIDE 50

Evaluating Nested Expressions

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

slide-51
SLIDE 51

Evaluating Nested Expressions

mul ( add(2, mul(4, 6)) , add(3, 5) ) add ( 2 , mul(4, 6) ) 26 mul add 2 mul ( 4 , 6 ) mul 4 6 24 add ( 3 , 5 ) add 3 5 8

slide-52
SLIDE 52

Evaluating Nested Expressions

208 mul ( add(2, mul(4, 6)) , add(3, 5) ) add ( 2 , mul(4, 6) ) 26 mul add 2 mul ( 4 , 6 ) mul 4 6 24 add ( 3 , 5 ) add 3 5 8