61A LECTURE 1 FUNCTIONS, VALUES. Steven Tang and Eric Tzeng June 24, 2013

Similar documents
CS61A Lecture 1. Amir Kamil UC Berkeley January 23, 2013

Welcome to CS61A! Last modified: Thu Jan 23 03:58: CS61A: Lecture #1 1

! The simplest building blocks of a language. ! Compound elements are built from simpler ones

378: Machine Organization and Assembly Language

61A Lecture 2. Wednesday, September 4, 2013

CSC 443: Web Programming

KOMAR UNIVERSITY OF SCIENCE AND TECHNOLOGY (KUST)

61A LECTURE 15 MEMOIZATION, RECURSIVE DATA, SETS

CS 1803 Pair Homework 3 Calculator Pair Fun Due: Wednesday, September 15th, before 6 PM Out of 100 points

EXPRESSIONS, STATEMENTS, AND FUNCTIONS 1

Welcome to CS 135 (Winter 2018)

Introduction to Data Structures

Introduction & Logistics

CIS192: Python Programming

CS61C Machine Structures. Lecture 1 Introduction. 8/27/2006 John Wawrzynek (Warzneck)

PhD Candidacy Exam Overview

Welcome to CS 135 (Fall 2018) Themes of the course. Lectures. cs135/

Lecture 1. Course Overview, Python Basics

COMPUTER SCIENCE IN THE NEWS. CS61A Lecture 21 Scheme TODAY REVIEW: DISPATCH DICTIONARIES DISPATCH DICTIONARIES 7/27/2012

61A Lecture 3. Friday, September 5

61A Lecture 2. Friday, August 28, 2015

EXPRESSIONS, STATEMENTS, AND FUNCTIONS 1

CS1 Lecture 13 Feb. 13, 2019

San Jose State University College of Science Department of Computer Science CS151, Object-Oriented Design, Sections 1, 2, and 3, Spring 2018

61A LECTURE 17 ORDERS OF GROWTH, EXCEPTIONS. Steven Tang and Eric Tzeng July 23, 2013

61A LECTURE 22 TAIL CALLS, ITERATORS. Steven Tang and Eric Tzeng July 30, 2013

Today. An Animated Introduction to Programming. Prerequisites. Computer programming

CSci 4211: Data Communications and Computer Networks. Time: Monday and Wednesday 1 pm to 2:15 pm Location: Vincent Hall 16 Spring 2016, 3 Credits

Lecture 1. Course Overview Types & Expressions

Welcome to CS 115 (Winter 2019)

Lecture 1. Course Overview, Python Basics

CS1 Lecture 3 Jan. 22, 2018

SAMS Programming A/B. Lecture #1 Introductions July 3, Mark Stehlik

You must pass the final exam to pass the course.

Please write your name and username here legibly: C212/A592 6W2 Summer 2017 Early Evaluation Exam: Fundamental Programming Structures in Java

Class Structure. Prerequisites

Basic Data Types and Operators CS 8: Introduction to Computer Science, Winter 2019 Lecture #2

CS1110 Lab 1 (Jan 27-28, 2015)


EECS 282 Information Systems Design and Programming. Atul Prakash Professor, Computer Science and Engineering University of Michigan

CS1 Lecture 3 Jan. 18, 2019

Introduction to Prof. Clarkson Fall Today s music: Prelude from Final Fantasy VII by Nobuo Uematsu (remastered by Sean Schafianski)

Announcements. 1. Forms to return today after class:

2005 University of California Undergraduate Experience Survey

SCHEME AND CALCULATOR 5b

CSE 240 Introduction to Computer Architecture

Welcome to CS 115 (Winter 2018)

CSCE 441 Computer Graphics Fall 2018

Lecture Programming in C++ PART 1. By Assistant Professor Dr. Ali Kattan

WELCOME! (download slides and.py files and follow along!) LECTURE 1

CS61A Lecture 9 Immutable Data Structures. Jom Magrotker UC Berkeley EECS July 2, 2012

CSC 015: FUNDAMENTALS OF COMPUTER SCIENCE I

CMSC 201 Computer Science I for Majors

Finding Pi: Applications of Loops, Random Numbers, Booleans CS 8: Introduction to Computer Science, Winter 2018 Lecture #6

Two Types of Types. Primitive Types in Java. Using Primitive Variables. Class #07: Java Primitives. Integer types.

Introduction to Prof. Clarkson Fall Today s music: Prelude from Final Fantasy VII by Nobuo Uematsu (remastered by Sean Schafianski)

CS270 Computer Organization Fall 2017

COMP Data Structures

CS240: Programming in C

COMP Data Structures

CMPS 182: Introduction to Database Management Systems. Instructor: David Martin TA: Avi Kaushik. Syllabus

Outline. Announcements. Homework 2. Boolean expressions 10/12/2007. Announcements Homework 2 questions. Boolean expression

EECS 282 Information Systems Design and Programming. Atul Prakash Professor, Computer Science and Engineering University of Michigan

CSC209. Software Tools and Systems Programming.

CS61A Discussion Notes: Week 11: The Metacircular Evaluator By Greg Krimer, with slight modifications by Phoebus Chen (using notes from Todd Segal)

Midterms Save the Dates!

Introduction to Prof. Clarkson Fall Today s music: Prelude from Final Fantasy VII by Nobuo Uematsu (remastered by Sean Schafianski)

CSE413: Programming Languages and Implementation Racket structs Implementing languages with interpreters Implementing closures

} Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = / 2; 3. int x = 5 / ; 4. double x = 5 / 2.


CSE 115. Introduction to Computer Science I

Intensive Introduction to Computer Science. Course Overview Programming in Scratch

Programming Languages and Techniques (CIS120)

CS 241 Data Organization using C

WELCOME TO CSE 100! Advanced Data Structures in C++

61A Lecture 9. Friday, September 20

CS/ENGRD 2110 FALL 2018

Assignment 7: Due Wednesday May 11 at 6pm UPDATES on Monday May 9

Computer Science II Data Structures

CS 326: Operating Systems. Lecture 1

Introduction to Programming System Design CSCI 455x (4 Units)

CS 241 Data Organization. August 21, 2018

AE Computer Programming for Aerospace Engineers

COMPUTER SCIENCE IN THE NEWS (TWO YEARS AGO) CS61A Lecture 16 Mutable Data Structures TODAY REVIEW: OOP CLASS DESIGN 7/24/2012

CS 61A Discussion 8: Scheme. March 23, 2017

WELCOME TO CS 16! Enrollment status: 117/ Problem Solving with Computers-I

Homework Assignment 2: Java Console and Graphics

CS 106B, Lecture 1 Introduction to C++

Computer Organization and Levels of Abstraction

CS61A Lecture 15. Amir Kamil UC Berkeley February 25, 2013

(Provisional) Lecture 08: List recursion and recursive diagrams 10:00 AM, Sep 22, 2017

Intro. Scheme Basics. scm> 5 5. scm>

CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims

Welcome to Computer Organization and Design Logic

Course Overview, Python Basics

Database Concepts. CS 377: Database Systems

CS 1803 Pair Homework 4 Greedy Scheduler (Part I) Due: Wednesday, September 29th, before 6 PM Out of 100 points

EECS150 Lab Lecture 0

61A LECTURE 7 DATA ABSTRACTION. Steven Tang and Eric Tzeng July 3, 2013

COMP 401 COURSE OVERVIEW

Transcription:

61A LECTURE 1 FUNCTIONS, VALUES Steven Tang and Eric Tzeng June 24, 2013

Welcome to CS61A!

The Course Staff - Lecturers Steven Tang Graduated L&S CS from Cal Back for a PhD in Education Eric Tzeng Graduated EECS from Cal Back for a PhD in Computer Science

The Course Staff TEACHING ASSISTANTS

Acknowledgement Thanks to: Amir Kamil, who we are borrowing many of the lecture slides from John DeNero, who has developed much of the course material, including the fantastic online readings

What is Computer Science? Computer science deals with the theoretical foundations of information and computation, together with practical techniques for the implementation and application of these foundations - Wikipedia Computer science uses computers to make cool stuff. - Steven Tang

What is CS61A? q An introduction to the big ideas in Computer Science q Functions, recursion, data structures, interpretation, parallelism... q Although the course uses Python, the ideas apply to any language q General focus: Using abstraction to manage complexity

What is Abstraction? Abstraction is exposing how to use something while hiding how it works Many layers of abstraction in a typical system Application Libraries (Graphics, Physics) Operating System Hardware (CPU, RAM, etc.) Logic Gates This course will teach you how to build and use abstractions

Some applications... Phones Cars Politics Games Education Movies Music Sports Anything connected to the Internet Systems Programming Languages Graphics Ar6ficial Intelligence Databases Theory Security Parallel Compu6ng Quantum Compu6ng

On to logistics.

Course Structure 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 Projects are larger assignments designed to teach you how to use and combine ideas from the course in interesting ways

Assignments and Grading ~2 homeworks per week, due on Mondays and Thursdays Homework 1 released later today, due Thursday 4 projects, one every 2 weeks Project 1 released tomorrow, due in ~2 weeks 2 midterms, 1 final Midterm 1 on Thursday, July 11 at 7PM Grading is on an absolute scale, rather than a curve See course website http://www-inst.eecs.berkeley.edu/~cs61a

Seems fast... CS61A in the summer moves roughly twice as quickly as the regular semester Start assignments early, and get help quickly Staff is here to help 8 teaching assistants 30+ (!!!) academic interns Use office hours, use Piazza

Piazza q We are using an online discussion form: https://piazza.com/class#summer2013/cs61a/ q Place to ask questions q Both instructors and fellow students can post replies q Official announcements will be posted to Piazza, so it is a requirement to use Piazza

Collaboration Remember: Grading is on a flat scale! Talk to 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! Limits of collaboration: Never share code (don t e-mail, copy paste, etc.) Copying projects is a serious offense. We have of ways of detecting duplicate work.

FAQ Midterms on 7/11 and 8/01 Final on 8/15 Let us know ASAP if you have any conflicts To waitlisted: In the summer, 61A is generally able to admit all students on the waitlist. Continue to complete and turn in assignments

Announcements Make sure you have an account form and register All assignments (homeworks and projects) are submitted through your account Account forms handed out in lab and discussion this week Office hours start Wednesday See website for schedule Homework 1 due Thurs. at 11:59PM

Break

Data, Functions, and Interpreters Data: the things that programs fiddle with UC Berkeley 2 (5, 3, 2) Functions: rules for manipulating data Count the words in a line of text Add up numbers Pronounce someone s name Interpreter: an implementation of the procedure for evaluation

Primitive Values and Expressions An expression is something that produces a data value. The simplest types of expressions produce a value directly. We call them primitive expressions. Integers: 42, -9001, 8417765 Floating point (decimal) values: 8.3, -39.2 Strings: It was a dark and stormy night Booleans: True, False A compound expression combines primitive expressions to produce a value. 2 + 3 sqrt(3004) abs(50 100 * 5)

Examples in the interpreter

Anatomy of a Call Expression add ( 2, 3 ) Operator Operand 0 Operand 1 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 operand subexpressions

Infix Expressions in Python Infix expressions can use function call notation 2 + 3 add(2, 3) 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

Summary of expressions Primitive expressions: 2 add 'hello' Call expressions: One big nested call expression Number Name String max ( 2, 3 ) Operator Operand 0 Operand 1 max(min(pow(3, 5), - 4), min(1, - 2)) Infix operators represent implicit call expressions 2 + 3 add(2, 3)

Remember the rules 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 operand subexpressions

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

Break

Recap of Expression Trees max(min(pow(3, 5), - 4), min(1, - 2)) Leaves are primi6ve expressions Operand 0 subexpression - 2 max(min(pow(3, 5), - 4), min(1, - 2)) Expression tree max - 4 min(pow(3, 5), - 4) - 2 min(1, - 2) min 243 pow(3, 5) - 4 min 1-2 pow 3 5

Types of Functions Pure Func6ons - 2 abs(number): Argument Return value 2 Only produces return values 2, 100 pow(x, y): 1267650600228229401496703205376 Non- Pure Func6ons - 2 print(...): Side effect Python displays the output - 2 Returns None! None Creates side effects, may return values The interac6ve interpreter displays all return values except None.

Back to the interpreter What do you think is printed by Python when you input: print(print(1), print(2)) Draw an expression tree.

Nested Print Expressions None, None print(...): None display None None None print(print(1), print(2)) print None print(1) print 1 None print(2) print 2 1 print(...): None 2 print(...): None display 1 display 2

The Elements of Programming Primitive Expressions and Statements The simplest building blocks of a language Means of Combination Compound elements built from simpler ones Means of Abstraction Elements can be named and manipulated as units

Reminders Account forms handed out in lab today Go to your section! Homework 1 is due Thursday Project 1 released tomorrow, due July 5 at 11:59PM Sign up for Piazza ASAP No office hours today; they start tomorrow