name: inverse layout: true class: center, middle, inverse --- # CS 61A – Discussion 1 ## Allen Guo ## http://aguo.us/cs61a --- layout: false # Announcements - Homeworks 0 and 1 due today - Labs 0 and 1 due tomorrow - Homework 2 due Tuesday - Hog due next Thursday - Midterm 1 is in two weeks --- class: center, middle, inverse ## There's a lot of strange vocabulary in computer science... --- class: center, middle ## Agile, AI, AngularJS, API, big data, cache, client-server, CPU, cryptocurrency, DAG, database, dependency injection, disk, filesystem, FSM, FTP, GNU, GPU, graphics, GUI, HTTP, interface, IoT, IRC, LAMP stack, Linux, loose coupling, machine learning, MVC, networking, Node.js, NoSQL, no-op, open source, OS, parallelization, PL, Python, RAM, React, redundancy, REST, robustness, SQL, SSH, TCP, threading, VCS, Vim, WWW, x86... --- # CS vs. Programming? -- - CS is something you study, programming is something you do -- - CS talks about what it is possible for *any* computer to do, programming solves problems for a specific computer (or subset of computers) -- - CS is what you pay to learn, programming is what you get paid to do .footnote[Source: [Quora](https://www.quora.com/Whats-the-difference-between-computer-science-and-programming) and [StackOverflow](https://softwareengineering.stackexchange.com/questions/137103/whats-the-difference-between-computer-science-and-programming)] --- # Terminal? GUI? -- - Terminal/shell.red[*]: window that allows you to issue commands to your computer efficiently without using a GUI -- - Bash: a specific kind of shell that is that's very popular -- - GUI (graphical user interface): allows you to interact with your computer through graphical icons and visual indicators -- - "At my internship I built a GUI for monitoring CPU usage" .footnote[.red[*] Not actually the same thing, but are very close] --- # Inside Your Computer -- - CPU (central processing unit): part of your computer that runs calculations and performs I/O - CPU usage: how much "compute power" you're using -- - I/O (input/output): reading and writing data -- - Memory (RAM): place for your CPU to store intermediate values during computation -- - Disk: place for storing things for the long term - This is what you see when you open Finder or Windows Explorer --- class: center, middle, inverse # Quiz --- class: center, middle # Lecture Recap --- # Syntax Confusions -- - `3.0` vs. `3` -- - `3.0` is a float (fractional value) but `3` is an int (integer value) - Floats are inaccurate: `3.0 + 1.9999999999999999` evaluates to `5.0` -- - `/` vs. `//` -- - `/` results in a float, `//` ("div") results in an int -- - `return` vs. `print` -- - `return` exits a function and indicates the result (return value) - `print` displays output to the user (and does not exit the function) --- # Functions as Values ```python def do_twice(f, x): return f(f(x)) def square(x): return x * x print(do_twice(square, 3)) ``` - What is printed when this code is run? -- - Answer: `81` -- - How many times is `square` called? -- - Answer: twice --- # Functions in Functions ```python def make_adder(n): def f(x): return x + n return f add_two = make_adder(2) print(add_two(add_two(0))) ``` - What is printed when this code is run? -- - Answer: `4` -- - How many frames are created total (not including the global frame)? -- - Answer: three --- class: center, middle, inverse # Worksheet