CompSci 101 Introduction to Computer Science January 15, 2015 Prof. Rodger 1.

Slides:



Advertisements
Similar presentations
Announcements You survived midterm 2! No Class / No Office hours Friday.
Advertisements

CompSci 101 Introduction to Computer Science February 3, 2015 Prof. Rodger Lecture given by Elizabeth Dowd.
How does Google search for everything? Searching For and Organizing Data Prof. Susan Rodger Computer Science Dept Duke University Oct. 31, 2014.
Python November 18, Unit 7. So Far We can get user input We can create variables We can convert values from one type to another using functions We can.
Search Lesson CS1313 Spring Search Lesson Outline 1.Searching Lesson Outline 2.How to Find a Value in an Array? 3.Linear Search 4.Linear Search.
CompSci 101 Introduction to Computer Science January 13, 2015 Prof. Rodger compsci 101 spring
INTERNET APPLICATION DEVELOPMENT For More visit:
CompSci 101 Introduction to Computer Science January 20, 2015 Prof. Rodger compsci 101, spring
Introduction to Python
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #001 (January 9, 2015)
1 CSC 221: Introduction to Programming Fall 2012 Functions & Modules  standard modules: math, random  Python documentation, help  user-defined functions,
COMP 171: Principles of Computer Science I John Barr.
Compsci 101.2, Fall PFTT (plan for this Thursday) l What is a Python program?  In the context of what we do in Compsci 101  In a neuroscience.
Compsci 101.2, Fall Plan For the Week l Solve problems by programming in Python  Like to do "real-world" problems, but we're very new to the.
Compsci 101.2, Fall Plan For the Day l Discuss Algorithms and Programming at a high level, examples with cooperative/group work  Connect to reading.
CompSci 101 Introduction to Computer Science September 23, 2014 Prof. Rodger.
How to Read Code Benfeard Williams 6/11/2015 Susie’s lecture notes are in the presenter’s notes, below the slides Disclaimer: Susie may have made errors.
CompSci 101 Introduction to Computer Science Sept. 9, 2014 Prof. Rodger President Brodhead speech graduation 2010 CompSci 101 Fall
Functions. Built-in functions You’ve used several functions already >>> len("ATGGTCA")‏ 7 >>> abs(-6)‏ 6 >>> float("3.1415")‏ >>>
1 CS161 Introduction to Computer Science Topic #9.
Introduction to Python Lesson 1 First Program. Learning Outcomes In this lesson the student will: 1.Learn some important facts about PC’s 2.Learn how.
CompSci 101 Introduction to Computer Science November 18, 2014 Prof. Rodger.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
CompSci 6 Introduction to Computer Science September 13, 2011 Prof. Rodger.
Compsci 101, Fall Plan For The Day (PFTD) l Practice solving problems  Some solved with a computer, some with Python  Differences in solving.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
Introduction to Programming Python Lab 3: Arithmetic 22 January PythonLab3 lecture slides.ppt Ping Brennan
CompSci 101 Introduction to Computer Science January 19, 2016 Prof. Rodger compsci 101 spring
CompSci 101 Introduction to Computer Science January 28, 2016 Prof. Rodger compsci101 spring161.
Introduction to Programming
Xi Wang Yang Zhang. 1. Easy to learn 2. Clean and readable codes 3. A lot of useful packages, especially for web scraping and text mining 4. Growing popularity.
CompSci 101 Introduction to Computer Science January 26, 2016 Prof. Rodger compsci 101, spring
CompSci 101 Introduction to Computer Science November 11, 2014 Prof. Rodger CompSci 101 Fall Review for exam.
CompSci 6 Introduction to Computer Science September 27, 2011 Prof. Rodger CompSci 6 Fall
CompSci 101 Introduction to Computer Science February 16, 2016 Prof. Rodger “All your troubles are due to those ‘ifs’,” declared the Wizard. If you were.
CompSci 4 Java 4 Apr 14, 2009 Prof. Susan Rodger.
Quiz 4 Topics Aid sheet is supplied with quiz. Functions, loops, conditionals, lists – STILL. New topics: –Default and Keyword Arguments. –Sets. –Strings.
CompSci 101 Introduction to Computer Science March 8, 2016 Prof. Rodger.
CompSci 101 Introduction to Computer Science February 5, 2015 Prof. Rodger Lecture given by Elizabeth Dowd compsci101 spring151.
CompSci 101 Introduction to Computer Science March 31, 2016 Prof. Rodger.
CompSci 101 Introduction to Computer Science Sept 13, 2016 Prof. Rodger compsci101 fall161.
Introduction to Programming
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
CompSci 6 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
Introduction to Programming
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
Variables, Expressions, and IO
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
Functions CIS 40 – Introduction to Programming in Python
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
Introduction to Programming
Prof. Susan Rodger Computer Science Dept Duke University Oct. 31, 2014
Introduction to Programming
CompSci 101 Introduction to Computer Science
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
Welcome to AP Computer Science A!
PFtTBSB Files and formats: how to read and store data
Introduction to Programming
Presentation transcript:

CompSci 101 Introduction to Computer Science January 15, 2015 Prof. Rodger 1

Don’t forget the rule You can’t sit in the last two rows That’s you! 2

Announcements Want a permission number to add course? –Fill out form on course web page (main page) Reading for next time, do RQ 3 Assignment 1 due Tuesday, Jan 20 APT 1 is out and due on Thursday, Jan 22 Today – Problem Solving, Python practice, solve an APT 3

Starting with Python Variable –Name of a storage location – holds a value = to assign a value to a variable Type –Different types of data –A variable can stores data of a certain type –int, float, str operators in Python for numbers –Arithmetic: + - * / % ** Built-in functions: pow, abs, round, int, float example: pow(2,3) + round (1.6) 4

Eclipse – Three ways to run 1.Write program and store in file –Create a PyDev project – a folder for programs –Create a PyDev module for each program (file) –Run in console 2.Snarf an APT and run in Eclipse 3.Run interactively –Open PyDev console –Execute each line as typed –Code not saved 5

Variables, Types, Expressions? a = 5 b = 4 c = "fred" print c print a + b * 3 print (a + b) * 3 print a / b print a / (b * 1.0) 6

Demo: Run interactively in Eclipse PyDev Console If Console window is not showing then –Click on Window, Show View, Console Then at the bottom of Eclipse, click here: Select PyDev Console, Python Console 7

Latanya Sweeney I am a computer scientist with a long history of weaving technology and policy together to remove stakeholder barriers to technology adoption. My focus is on "computational policy" and I term myself a "computer (cross) policy" scientist. I have enjoyed success at creating technology that weaves with policy to resolve real-world technology-privacy clashes. Identify 87% of US population using (dob,zip,gender). Director of Harvard Data Privacy Lab, instrumental in HIPAA because if de-identification work, currently Chief Technologist FTC 8

Function – define vs call def functionName(parameters): block def sum(a, b): return a+b Call function sum(7, 4) sum(“a”, “cat”) Advantages –Repeat code, call multiple times –Flexible, call with different arguments 9

Demo 2 In Eclipse write a file with a function and run Stuff.py 10

What is an APT? BMI APTBMI APT Automated/Algorithmic Problem Testing –Write one function, 2-30 lines, solve a problem –Tested automagically in Eclipse or the browser –Lots of test cases – test test test Start simple, build toward more complex –What is a function? A function call? –What is a parameter? Argument? –How do you run/execute a program 11

Demo 3 on Solving APT BMI Write your code in Eclipse Snarf the apt testing materials –Create the python file in apt folder –Write your code Run in Eclipse or Run on the web 12

Skills and Practice for Game Playing $193, $540, $820, $700, $749. Are these reasonable? Why? 13

I'm thinking of a number … bit.ly/101S You guess. I'll tell you high, low, or correct –Goal: guess quickly, minimal number of guesses –Number between 1 and 100… –Number between 1 and 1000… Can you describe an algorithm, instructions, that would allow someone to use your instructions to play this game correctly. Start with 1 and 100, but ideally your instructions work with 1 and X 14

Analyzing the binary search algorithm Is the algorithm correct? –Try it, again, and again and … –Reason about it: logically, informally, … How efficient is the algorithm? –How many guesses will it take (roughly, exactly) –Should we care about efficiency? When do we really care about efficiency? –Examples? 15

Anderson Applegate Bethune Brooks Carter Edwards Foggle Griffin Holhouser Jefferson Klatchy Morgan Munson Narten Oliven Parken Rivers Roberts Stevenson Thomas Wilson Woodrow Yarbrow Find Narten 16

Anderson Applegate Bethune Brooks Carter Edwards Foggle Griffin Holhouser Jefferson Klatchy Morgan Munson Narten Oliven Parken Rivers Roberts Stevenson Thomas Wilson Woodrow Yarbrow X X X Find Narten Found! How many words did we look at? 17

Searching for words If we had a million words in alphabetical order, how many would we need to look at worst case to find a word? 18

Searching for words If we had a million words in alphabetical order, how many would we need to look at worst case to find a word? 20 1,000, , , ,000 62,500 31,250 15, If you are clever, Cut the number of numbers to look at in half over and over again, Then only 18 numbers to look at worst case 19