CS1 Lecture 2 Jan. 16, 2019

Similar documents
CS1 Lecture 3 Jan. 22, 2018

CS1 Lecture 3 Jan. 18, 2019

CS1 Lecture 4 Jan. 23, 2019

CS1 Lecture 5 Jan. 25, 2019

CS1 Lecture 22 Mar. 6, 2019

CS1 Lecture 5 Jan. 26, 2018

Programming for Engineers in Python

Introduction to Scientific Python, CME 193 Jan. 9, web.stanford.edu/~ermartin/teaching/cme193-winter15

Lecture Transcript While and Do While Statements in C++

CS1 Lecture 12 Feb. 11, 2019

CS 241 Data Organization. August 21, 2018

Computer Science 210: Data Structures

CS1 Lecture 13 Feb. 13, 2019

Scientific Computing: Lecture 1

Unit 7: Algorithms and Python CS 101, Fall 2018

Programming with Python

Objectives. Structure. Munster Programming Training

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

Week - 01 Lecture - 04 Downloading and installing Python

Lecture 1. Course Overview, Python Basics

Introduction to Sets and Logic (MATH 1190)

CS 150 Introduction to Computer Science 1. August 31, 2009

Slide Set 2. for ENCM 335 in Fall Steve Norman, PhD, PEng

CS 150 Introduction to Computer Science 1

CME 193: Introduction to Scientific Python Lecture 1: Introduction

Scientific Computing for Physical Systems. Spring semester, 2018

Introduction to: Computers & Programming: Review prior to 1 st Midterm

CS120 Computer Science I. Instructor: Jia Song

CS 31: Introduction to Computer Systems. 03: Binary Arithmetic January 29

Lecture 17: Hash Tables, Maps, Finish Linked Lists

CS1 Lecture 4 Jan. 24, 2018

CS 4349 Lecture October 18th, 2017

CS Introduction to Programming Fall 2016

ITP489 In-Memory DBMS for Real Time Analytics

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #44. Multidimensional Array and pointers

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

Course Overview, Python Basics

3D Graphics Programming Mira Costa High School - Class Syllabus,

More Examples Using Functions and Command-Line Arguments in C++ CS 16: Solving Problems with Computers I Lecture #6

Review for the Final Exam CS 8: Introduction to Computer Science, Winter 2018 Lecture #15

If Statements, For Loops, Functions

CS1210 Lecture 28 Mar. 27, 2019

COMP 401 COURSE OVERVIEW

Class Note #02. [Overall Information] [During the Lecture]

Welcome to CS 115 (Winter 2018)

CS 4349 Lecture August 21st, 2017

Physics 2660: Fundamentals of Scientific Computing. Lecture 5 Instructor: Prof. Chris Neu

CS 190C: Introduction to Computational Thinking

CSCI 136 Data Structures & Advanced Programming. Spring 2018 Instructors Bill Jannen & Jon Park

MS6021 Scientific Computing. MatLab and Python for Mathematical Modelling. Aimed at the absolute beginner.

Lecture 1. Course Overview, Python Basics

6.S189 Homework 1. What to turn in. Exercise 1.1 Installing Python. Exercise 1.2 Hello, world!

CS1 Lecture 31 Apr. 3, 2019

CS1 Lecture 9 Feb. 5, 2018

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

COMP 117: Internet-scale Distributed Systems Lessons from the World Wide Web

More About WHILE Loops

2: Complexity and Recursion

CSE 240 Introduction to Computer Architecture

Computer Science II Lecture 1 Introduction and Background

Beyond Blocks: Python Session #1

CS1 Lecture 11 Feb. 9, 2018

COMP Data Structures

Project 5 - The Meta-Circular Evaluator

COMP Data Structures

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

CS33 Project Gear Up. Data

CIS 3308 Web Application Programming Syllabus

ECE573 Introduction to Compilers & Translators

BCIS 3630 Dr. GUYNES SPRING 2018 TUESDAY SECTION [JAN version] GRADER COURSE WEBSITE

Design and Debug: Essen.al Concepts CS 16: Solving Problems with Computers I Lecture #8

Lecture 1. Course Overview Types & Expressions

School of Computer Science

Note that in this definition, n + m denotes the syntactic expression with three symbols n, +, and m, not to the number that is the sum of n and m.

CMSC 201 Spring 2017 Project 1 Number Classifier

EECS 203 Lecture 20. More Graphs

High-Performance Scientific Computing

: Dimension. Lecturer: Barwick. Wednesday 03 February 2016

CSCI 136 Data Structures & Advanced Programming. Fall 2018 Instructors Bill Lenhart & Bill Jannen

Boca Raton Community High School AP Computer Science A - Syllabus 2009/10

Genome 559 Intro to Statistical and Computational Genomics Lecture 15b: Classes and Objects, II Larry Ruzzo

Python for Analytics. Python Fundamentals RSI Chapters 1 and 2

Course: Honors AP Computer Science Instructor: Mr. Jason A. Townsend

Scientific Computing

CS 241 Data Organization using C

AMath 483/583 Lecture 2

CS 3030 Scripting Languages Syllabus

CSE 240 Introduction to Computer Architecture

AMath 483/583 Lecture 2. Notes: Notes: Homework #1. Class Virtual Machine. Notes: Outline:

ESET 349 Microcontroller Architecture, Fall 2018

Reviewing all Topics this term

(Refer Slide Time: 05:25)

CSC2100-Data Structures

Module 10A Lecture - 20 What is a function? Why use functions Example: power (base, n)

Introduction to Software Testing Chapter 3.1, 3.2 Logic Coverage Paul Ammann & Jeff Offutt

Introduction to Software Testing Chapter 3.1, 3.2 Logic Coverage Paul Ammann & Jeff Offutt

KOMAR UNIVERSITY OF SCIENCE AND TECHNOLOGY (KUST)

CS221: Algorithms and Data Structures. Asymptotic Analysis. Alan J. Hu (Borrowing slides from Steve Wolfman)

Semester 2, 2018: Lab 1

Introduction to Software Testing Chapter 3, Sec# 1 & 2 Logic Coverage

Transcription:

CS1 Lecture 2 Jan. 16, 2019 Contacting me/tas by email You may send questions/comments to me/tas by email. For discussion section issues, sent to TA and me For homework or other issues send to me (your discussion section TA might not be involved in grading your homework) DO NOT sent multiple messages (one to TA, one to me). This often wastes people s time and makes a mess! For homework-related email: ALWAYS attach file of your current code. Don t just copy/paste code into message body! TA office hours times and locations will be published Friday You can go to any TA office hours, not just TA of your discussion section. First homework will be available Monday, Jan. 21, due Mon. Jan. 28, 9am (but practice some Python right away!)

Today Course overview Chapter 1 of text Programs Python Evaluating simple expressions Types Natural vs formal languages (debugging will be deferred until later) Example GUI/web program demo you ll soon be able to create Graph problems posed at end of first lecture

Course overview 6 weeks basic python programming Expressions, types, variables, conditions, functions, iteration Use of sequence and dictionary data types Additional topics (approx. one week each) Classes and object oriented programming Comprehensions and other more powerful Python language tools Program design and debugging Algorithmic efficiency Searching and sorting GUIs Graphing, plotting Accessing web data Machine learning or other advanced topics

Ch 1: Programs Textbook: A program is a sequence of instructions that specifies how to perform a computation. Many people like to distinguish algorithm and program. dictionary.com: An algorithm is a finite set of unambiguous instructions performed in a prescribed sequence to achieve a goal. (non-computing examples?) I like to say: program = algorithm + programming language or: Programming is the process of expressing an algorithm in a programming language (so you can execute it on a computer)

Ch 1: Programs Key components of programming, independent of particular programming language. Expressions Variables and assignment if-then-else (decision making/branching) Iteration Functions Essentially all programming languages are built around these components. Once you understand how to describe computations using them, you can program. Learn these basics well! Changing programming languages is usually just a matter of looking up details of how to say a particular standard thing in the different language.

Ch 1: Python There are many many programming languages! Why Python? Clean syntax, powerful constructs enable beginners to more quickly get computer to do interesting things Interactive mode encourages experimentation Extensive standard and third party libraries for web programming, scientific computation, data analysis, etc. https://xkcd.com/353/

Ch 1: Using Python Book encourages starting with browser-based Python. I recommend instead that you install Python with Idle or Anaconda on your own machine (see course website) When working with Python, we will usually use a Python interpreter, which is a program that reads Python code and executes it. Demo: Python interpreter via pythonanywhere.com Demo: Python interpreter from Mac terminal Demo (the most common way I will do things and recommended approach for students): Python interpreter plus IDLE IDE. Demo: Anaconda s Spyder IDE

Ch 1: expressions, arithmetic, types You can use the Python interpreter like a calculator, typing in many different mathematical (and other) expressions and seeing immediate results print( hello ) 3 + 2 2**128 5/2+1 Expressions yield values. Every value has a type. 3 s type in int (for integer) 3.5 s type is float (for floating point number) (What about 3.0? 3.0 s type is float. It is not the exact same thing as 3 in Python but (fortunately) it is equal to 3. More on this later.) hello s type is string You can ask Python for a value s type >>> type(3.5) (Note: don t use commas in big numbers: 1,000,000 is not million in Python!)

Again basic programming components, independent of particular programming language. Expressions Variables and assignment if-then-else (decision making/branching) Iteration Functions Expression: 3 + (2 * b) Assignment: counter = 1 counter = counter + 2 Decision making: if counter > 0: print( counter is positive ) else: print( counter is not positive ) Iteration: while (counter > 0): print(counter * counter) counter = counter 1 Function: def plus5(number): return number + 5

Ch 1: natural vs formal languages One major difference: formal programming languages are unambiguous. Natural languages are ambiguous, which can be annoying and confusing but also enables playfulness and creativity (jokes, poetry, etc.) Natural languages have lots of redundancy many ways to express the same thing. Programming languages also redundant but less so. Programming languages are dense but they can be directly and unambiguously translated into basic machine-level operations Computer systems read them quickly but humans need to read them too. STRONG RECOMMENDATION: get in the habit of reading programs slowly, carefully, and critically. Make sure you understand what they really say rather than what you believe or hope they say)

IC Arrest Blotter Demo: blotter.py Later in the semester you should be able to make this program.

Problems from end of last class (examples of computational complexity) Euler vs Hamiltonian circuits and TSP. Graphs in computer science: different notion than the graphical plots taught in high school 6 4 2 0 2010 2011 2012 2013 VS. 1. Can you find a path that traverses every edge (connection) exactly once? 2. Can you find a path that visits every node (vertex) exactly once? 3. If the edges are assigned weights (representing distance/cost to traverse), can you find path of minimum cost that visits every node exactly once? Are these similarly computationally hard or easy? Solve for extra credit?

(Euler paths/circuits i.e. problem 1 - examples drawn/shown via doc cam) Problem 1 is easy! Super fast, efficient algorithm Problems 2 and 3 are very hard! No efficient optimal solutions are known (and might not exist)

The next two slides were not shown in Lecture 2 but contain links to web pages/videos giving nice information about the difficulty of the third path-finding problem

Source: http://toddwschneider.com/posts/traveling-salesman-with-simulated-annealing-r-andshiny/

Source: http://toddwschneider.com/posts/traveling-salesman-with-simulated-annealing-r-andshiny/ See also nice short video at:http://www.youtube.com/watch?v=sc5cx8dratu&list=plxh6ufue9gktm5-bbfmtp_1-avaniuiq&index=3

Next time- very important basics More on values, expressions, and types Functions For next time, read: Ch2, and Ch3 up through Adding New Functions