1 / 60

CS 60

CS 60. Introduction to CS 60 and Racket. 2013-09-03 Wednesday – Week 0 Lecture 01. Lecture 01 – Learning Goals. Can find help (grutors, piazza, etc). Can write Racket functions using if , cond , let , quotient , and recursion! Can debug Racket code using test cases & trace

yoshi-walls
Télécharger la présentation

CS 60

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 60 Introduction to CS 60 and Racket 2013-09-03 Wednesday – Week 0 Lecture 01

  2. Lecture 01 – Learning Goals • Can find help (grutors, piazza, etc). • Can write Racket functions using if, cond, let, quotient, and recursion! • Can debug Racket code using test cases & trace • Can trace recursion using the strategies of • Forward • Backwards • One step

  3. CS 60 Intro

  4. Introductions... Colleen Lewis Olin 1280 lewis@cs.hmc.edu fan of swimming/sleeping fan of baking

  5. CS 60 vs. CS 5 CS 5's goals Solving computational problems in one language (Python) Conveying some of CS's breadth; CS 60's goals Solving computational problems in several different languages! Understandingcomputational problems their difficulty and limitations solution principles and efficiency Conveying more of CS's depth I'm sure it's just a coincidence that this CS 60 stuff definitely seems more alien

  6. Syllabus, briefly Lectures Mon/Wed : 2:45-4:00pm Key skills, topics, and their motivation Insight into the HW problems (what, why, how) laptops not encouraged Required! Let me know if you won’t make it iClickers starting Thursday Website http://www.cs.hmc.edu/courses/2014/fall/cs60/ Tutors and tutoring hours LOTS!! See website... Post anonymously or not Post to the whole class or “private” (Private goes to Colleen and grutors – if you include code) Email help Piazza! Office Hours Monday/Wednesday 4-4:55 (after class) & Tuesday 11:00-12:30 (in the LAC lab) OR by appointment

  7. Tutoring Hours LAC Computer Lab (2nd floor)

  8. Tutoring Hours LAC Computer Lab (2nd floor)

  9. Important Dates • Take-home Racket Quiz • due Wednesday, Oct 8th 4:30pm • 50 points • time limit: 60 minutes • 1 page of notes (front + back) • Take-home Prolog Quiz • due Thursday, Oct 23rd 4:30pm • 50 points • time limit: 90 minutes • 1 page of notes (front + back) • Take-home Java Quiz • Due Thursday, Nov 20th 4:30pm • 50 points • time limit: 60 minutes • 1 page of notes (front + back) • In-class Final Exam • Monday, Dec 15th 2:00-5:00pm • 200 points • time limit: 3 hours • 4 pages of notes (front + back)

  10. Grade Components and Grading • Weekly homework (12 total): 1200 points (~75%) • Racket Quiz: 50 points (~3%) • Prolog Quiz: 50 points (~3%) • Java Quiz: 50 points (~3%) • Final exam: 200 points (~13%) • Participation: 50 points (~3%) (define (score p) (cond ((>= p 0.95) "A") ((>= p 0.90) "A-") ((>= p 0.87) "B+") ((>= p 0.83) "B") ((>= p 0.80) "B-") ((>= p 0.70) "C range") ((>= p 0.60) "passing") (else "hopefully NA")))

  11. Grade Components and Grading • Participation: • Asking/Answering questions on piazza • Attendance • In-class “quizzes” • (not performance based) • Being a good CS60 citizen • Weekly homework (12 total): 1200 points (~75%) • Racket Quiz: 50 points (~3%) • Prolog Quiz: 50 points (~3%) • Java Quiz: 50 points (~3%) • Final exam: 200 points (~13%) • Participation: 50 points (~3%)

  12. Problem 1: fun! Don’t stress about tutorial parts 6-8 Problem 2 must be MORE fun!

  13. Intro to Racket

  14. DEMO

  15. DEMO: Calling Functions Not 3 + 4 Calling two functions?Work from the inside-out Someone designed these to make sense.EVERYTHING should make sense!

  16. DEMO: Labeling Data String Helpful error messagesREAD THEM Label data

  17. How to Label Data (define a (+ 2 3)) (define addFunc +) (define variable value) Keyword An expression Shouldn’t be an expression

  18. ENDDEMO

  19. quotient vs /

  20. How to label functions Formal parameters Function Name Body Keyword Actual argument values

  21. DEMO

  22. DEMO: procedures/parens #t and #fare Booleans Procedures are just things No extra parens! Racket thinks the thing after a paren is a function

  23. How to use if & cond (if <predicate> <true case> <false case> ) (cond [<test1> <result> ] [<test2> <result> ] [else <result> ]) (define (warm temp) (if (> temp 75) "warm" "cold")) (define (cool temp) (cond [(> temp 75) "hot"] [(< temp 65) "cold"] [ else "ok"]))

  24. How to use Let (create new variables in definitions) (let ( [<variable1> <value1>] [<variable2> <value2>] ) <body> ) (define (spam) (let ([a 3] [b 4]) (+ a b) ))

  25. ENDDEMO

  26. Racket Testing and Debugging

  27. Try these! Solutions provided in hw0pr2.rkt

  28. Try these! Solutions provided in hw0pr2.rkt

  29. Testing in Racket Import the library Sample test Sample output Run tests

  30. Tracing in Racket Import the library Tell it to trace add42 Sample output It tells you what input add42 was run with!

  31. Tracing in Racket (to Debug!) Import the library (require racket/trace) (trace fac) Use this to see what recursive calls get made

  32. Write Test Cases Write simple cases first!

  33. Recursion

  34. Methods for Tracing Recursive Code • Forward • Backward • One step

  35. The Factorial Function (define (fact x) (if (<= x 1) 1 (* x (fact (- x 1)))))

  36. Forward (define (fact x) (if (<= x 1) 1 (* x (fact (- x 1)))))

  37. Forward (define (fact x) (if (<= x 1) 1 (* x (fact (- x 1)))))

  38. Backward (define (fact x) (if (<= x 1) 1 (* x (fact (- x 1))))) (fact 1) = 1 (fact 2) = (* 2 (fact 1)) = 2 (fact 3) = (* 3 (fact 2)) = 6 (fact 4) = (* 4 (fact 3)) = 24 (fact 5) = (* 5 (fact 4)) = 120 (fact 6) = (* 6 (fact 5)) = 720

  39. One Step (define (fact x) (if (<= x 1) 1 (* x (fact (- x 1))))) (fact 8) = (* 8 (fact 7)) What is (fact 7)?

  40. Methods for Tracing Recursive Code • Forward • Backward • One step

  41. Pair Programming

  42. Pair Programming • On some problems, you may pair program – do! • You must practice "pair programming" • both people at the computer at the same time • trade off "driver" and "navigator" every 30 mins • both people contribute to the solution • Individual problems must be completed individually • Be sure to read syllabus Collaboration Policy!

  43. BONUS

  44. Estimating Time • Most people grossly underestimate how long it takes to program (not thinking about time to debug and test) • You appear incompetent at programming (not true) if you can’t estimate how long something will take. • This is one of the hardest things to learn!!! Start to practice now! For each task estimate how long it will take and keep track of how wrong you were

  45. Computer Science & = AWESOME

  46. http://www.youtube.com/watch?v=pzRmNYA8LlY

  47. ClickStart

More Related