knowledge-kitchen
/
course-notes
class: center, middle # Welcome Intro to Computer Science --- # Agenda 1. [Introductions](#introductions) 2. [What you know you knew](#know-knew) 3. [What you didn't know you knew](#didnt-know-knew) 4. [What you knew you didn't know](#knew-didnt-know) 5. [What you didn't know you didn't know](#didnt-know-didnt-know) 6. [How this course works](#how-course-works) 7. [What to do now](#do-now) 8. [Conclusions](#conclusions) --- name: introductions # Introductions --- template: introductions name: introductions-1 ## This course Introduction to Computer Science - Syllabus: [syllabus](/content/courses/intro-to-computer-science/syllabus/) - Schedule: [schedule](/content/courses/intro-to-computer-science/schedule/) --- template: introductions-1 Official description: > How to design algorithms to solve problems and how to translate these algorithms into working computer programs. Experience is acquired through projects in a high-level programming language. Intended primarily for computer science majors but also suitable for students of other scientific disciplines. Programming assignments. --- template: introductions ## Me Foo Barstein - discord: @foo.barstein --- template: introductions ## You - Probably an aspiring programmer. - Perhaps an aspiring computer scientist. - Hopefully interested in making things and solving problems. - Willing to spend hours by yourself reading and staring at code. --- template: introductions ## Computer science The study of the theory and practice of computation. Very open-ended. ```python not programming == computer_sciencing ``` ```python computer_sciencing.find(computers) == -1 ``` ```python computer_sciencing not in sciences ``` --- name: know-knew # What you know you knew --- template: know-knew ## Data types Programs usually think of data in terms of rigid stereotypes. - integers - floating point numbers - booleans - strings - lists - dictionaries/hash tables/associative arrays - nonetypes/null/nil Review [data types](/content/courses/intro-to-programming/data-types/). --- template: know-knew ## Input and output There are many ways to input and output data from / to external sources. ```python response = input("What's brown and sticky?") ``` ```python print("'{}' is correct!".format(response.capitalize())) ``` Review [input and output](/content/courses/intro-to-programming/input-output/). --- template: know-knew ## Boolean logic and decision-making Programs can adapt to context. ```python if this or that and the_other is not also_that: thats_wonderful() ``` Review [boolean logic](/content/courses/intro-to-programming/boolean-logic/) and [decision-making](/content/courses/intro-to-programming/decision-making/). --- template: know-knew ## Functions Functions are modular blocks of code usually designed to perform a single task. ```python def thats_wonderful(): print("That's wonderful") ``` Review [functions](/content/courses/intro-to-programming/functions/). --- template: know-knew ## Modules A module is a simply a reusable library of code. ```python # import random module import random def thats_wonderful(): # use a function from the random module if random.randint(1,10) > 5: print("That's wonderful") else: print("Okay...") ``` Review [modules](/content/courses/intro-to-programming/modules/). --- template: know-knew ## For loop and while loops You have choices when repeating blocks of code. ```python for i in range(10): print("Welcome!") ``` ```python i = 0 while i < 10: print("Welcome!") i = i + 1 ``` Review [for loops](/content/courses/intro-to-programming/loops-for/) and [while loops](/content/courses/intro-to-programming/loops-while/). --- template: know-knew ## Lists Lists are useful for storing a set of related values. ```python favorite_foods = [ "Pizza with glyphosate-coated bleached wheat flour and soy cheese", "Coffee with GMO corn syrup solids added", "Emulsified non-fat sugar-free ice cream with artificial sweetener" ] ``` Review [lists](/content/courses/intro-to-programming/list-basics/) and [more lists](/content/courses/intro-to-programming/list-more/). --- template: know-knew ## Dictionaries Dictionaries contain key/value pairs. ```python phone_numbers: { "Foo Barstein": "646-888-5623", "Baz Foo": "212-717-3297", "Bar Baz": "747-211-8451" } ``` Review [dictionaries](/content/courses/intro-to-programming/dictionary-basics/) and [more dictionaries](/content/courses/intro-to-programming/dictionary-more/). --- template: know-knew ## Text files Data can be stored and retrieved from text files. ```python # open file in read mode f = open('data.csv', 'r') ``` ```python # print out each line of the file for line in f: data = line.split(",") ``` Review [text files](/content/courses/intro-to-programming/text-files/). --- template: know-knew ## Strings Languages offer many ways to analyze and manipulate text data. ```python text = "This,That,The other" text = text.lower() pos = text.find(",") if pos > 0: data = text.split(",") ``` Review [strings](/content/courses/intro-to-programming/string-basics/) and [string formatting](/content/courses/intro-to-programming/string-formatting/). --- name: didnt-know-knew # What you didn't know you knew --- template: didnt-know-knew ## Variables, literals, expressions, and function calls There are many ways to express value in programs. ```python "I am literally a literal" ``` ```python I_am_not ``` ```python math.pow(washington, 2) + park ``` Review [variables, literals, and expressions](/content/courses/intro-to-programming/variables-literals-expressions/). --- template: didnt-know-knew ## Dot notation Dots indicate belongingness. ```python random.randint(5, 10) ``` ```python math.pow(2, 2) ``` ```python 'help me'.islower() ``` --- template: didnt-know-knew ## Other languages Try to convince me that you don't understand this code: ```js let x = 5; let y = true; if (x < 10 and y == true) { console.log("Easy peasy!"); } ``` ```java int x = 5; boolean y = true; if (x < 10 and y == true) { System.out.println("Easy peasy!"); } ``` --- name: knew-didnt-know # What you knew you didn't know --- template: knew-didnt-know A popular way to think about programs with interacting parts. - Object-oriented programming ```python you = new Student("Jane Doe") ``` ```python me = new Professor("Foo Barstein") ``` ```python me.say_hello(you) ``` Jump ahead half a semester to [object-oriented programming](../object-orientation/) --- name: didnt-know-didnt-know # What you didn't know you didn't know --- template: didnt-know-didnt-know name: didnt-know-1 ## Basic computer concepts and terminology Can you answer these questions? - What is a file? What is a folder? -- - What are good names for files and folders? -- - How do you use the command line? -- - What is a compiler? What is an interpreter? An assembler? -- - What is an operating system? What is an application? -- - What is the Internet? What is The World Wide Web? -- - What is The Cloud? -- Review [basic computer concepts](/content/courses/intro-to-computer-science/basic-computer-concepts/). --- template: didnt-know-didnt-know ## Alias vs. copy What is printed? ```python x = 5 y = x x = 10 print(y) ``` Try it out yourself. --- template: didnt-know-didnt-know ## Raw strings How many lines are printed? ```python x = "First line\nSecond line" print(x) ``` ```python x = r"First line\nSecond line" print(x) ``` Learn about [raw strings](/content/courses/intro-to-programming/string-raw/). --- template: didnt-know-didnt-know ## Multidimensional arrays ```python row1 = [1, 2, 3] row2 = [4, 5, 6] row3 = [7, 8, 9] ``` ```python data = [row1, row2, row3] ``` ```python print(data[1][2]) ``` Jump ahead half a semester to [multi-dimensional arrays](../arrays-multidimensional/). --- template: didnt-know-didnt-know ## Recursion How many times is the function called? ```python def foo(x): if x < 3: foo(x+1) foo(x+1) foo(1) ``` Jump ahead almost a semester to [recursion](../recursion/). --- template: didnt-know-didnt-know ## You can place out of this class If you are comfortable with multi-dimensional arrays, object-oriented programming, and recursion, consider taking a placement exam to skip this course. Learn about [placement exams](https://cs.nyu.edu/home/undergrad/placement_sample_exams.html). --- name: how-course-works # How this course works --- template: how-course-works name: how-course-works-1 ## Lecture I will speak for 75 minutes about twice each week.... that's 150 minutes of talking each week. -- I sincerely hope for your sake and mine that you will interrupt me and ask lots of questions. --- template: how-course-works ## Notes I write notes for most lecture topics. You may find them useful but incomplete. --- template: how-course-works ## Slides Students constantly request slides, so I have made them. However, I believe you are better off reviewing documents and code. Each slide has a link to its "source" document, which may be easier to read. --- template: how-course-works ## Reading Reading assignments from [the textbook](/content/courses/intro-to-computer-science/syllabus/#textbook) and elsewhere each class. The textbook is quite thorough. --- template: how-course-works ## Assignments You will have somewhere around 10 assignments. You lose 10 points for each day late and we do not accept submissions more than 3 days late. See the complete [lateness policy](/content/courses/intro-to-computer-science/syllabus/#late-policy). --- template: how-course-works name: extensions ## Extensions Please do not ask for an extension. -- You are hereby granted 2 free extensions for work submitted up to 3 days past the due date. --- template: how-course-works ## Quizzes Regular simple multiple-choice online quizzes. These are meant to help you self-assess your own mastery of conceptual material. --- template: how-course-works ## Exams You will take 3 exams. Many find the first exam to be easy. The second and third... not so much! Students who come to class tend to do better. --- template: how-course-works ## Grading - 25% quizzes - 35% assignments - 10% first exam - 15% second exam - 15% third exam --- template: how-course-works ## Communication We use Dicord for all communication outside of the classroom. You must create a private channel in Discord. Check the complete [Discord details](/content/courses/intro-to-computer-science/syllabus/). --- template: how-course-works ## Tutoring Tutors are waiting to answer your questions virtually all day every day of the week. See them often. See them fast. Check the complete [tutoring schedule](/content/courses/intro-to-computer-science/syllabus/#tutoring). --- name: what-now # What to do now --- template: what-now ## Review the syllabus The [syllabus](/content/courses/intro-to-computer-science/syllabus/) contains basic information on how this course works. --- template: what-now ## Bookmark the schedule The [schedule](/content/courses/intro-to-computer-science/schedule/) contains a day-by-day breakdown of everything you need to know and do in this course. --- template: what-now ## Complete the consent form Your consent is necessary since we use software that is not obliged to abide by the Family Educational Rights and Privacy Act. [Complete the form](https://goo.gl/forms/uxxgA3D9F3kA0KAR2) Contact me if you have concerns about privacy. --- template: what-now ## Download and JDK version 8 The Java Development Kit (JDK) is a necessary set of tools that help develop Java programs. Install the Standard Edition (SE). We use the older version 8 because it is compatible with [Processing](https://processing.org), which we will use later in this course, whereas Processing is not compatible with newer versions of the JDK. https://www.oracle.com/java/technologies/downloads/#java8 --- template: what-now ## Download and install Visual Studio Code Visual Studio Code is an Integrated Development Environment (IDE) that integrates with the JDK to allow you to easily write and debug Java programs. https://code.visualstudio.com --- template: what-now ## Download and install the Extension Pack for Java These extensions to Visual Studio Code make it suitable for Java programming. https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack --- template: what-now ## Install Git Get git [for Mac](https://git-scm.com/downloads) or [Git for Windows](https://gitforwindows.org/). - Git for Windows additionally comes with Git Bash, which gives Windows users a UNIX-like command shell. - WINDOWS USERS - you should use Git Bash or Windows Subsystem for Linux (WSL) rather than Windows' default Powershell or other command line shell program. To set Git Bash or WSL as the default terminal shell within Visual Studio Code, you can try to follow the instructions in [the second answer here](https://stackoverflow.com/questions/42606837/how-do-i-use-bash-on-windows-from-the-visual-studio-code-integrated-terminal) by **Mahade Walid** and edited by **FruityOatyBar** (ignore the first answe, which is outdated). - Mac users already have a UNIX command shell in the Terminal app. --- name: conclusions # Conclusions -- - Welcome! -- - Start to think like a compiler... or is it an interpreter... or an assembler? -- ```python print("There's no reason to worry... {}".format("yet!")) ``` -- - Thanks. Bye.