Compsci 101, Fall 2012 2.1 Plan For The Day (PFTD) l Practice solving problems  Some solved with a computer, some with Python  Differences in solving.

Slides:



Advertisements
Similar presentations
PHP Intro/Overview Squirrel Book pages Server-side Scripting Everything you need to know in one slide 1.Web server (with PHP “plug-in”) gets a.
Advertisements

Program Design and Development
Copyright 2008 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
Methods: a first introduction Two ways to make tea: 1: boil water; put teabag into cup;... etc : tell your younger brother: makeTea(1 milk, 0 sugar);
Software design and development Marcus Hunt. Application and limits of procedural programming Procedural programming is a powerful language, typically.
Recitation 1 Programming for Engineers in Python.
CompSci 101 Introduction to Computer Science January 13, 2015 Prof. Rodger compsci 101 spring
Lecture 2 - Variables, program execution, calculations, print() COMPSCI 101 Principles of Programming.
PYTHON. Python is a high-level, interpreted, interactive and object- oriented scripting language. Python was designed to be highly readable which uses.
Compsci 101, Fall Plan for the week: Week 2, Sept 1-5 l Understanding program structure  Defining, testing, calling functions  How to run a.
Compsci 06/101, Fall Compsci 6/101: Sept 6-10 l We've looked at the language Python  Names and types: int, float, long, String, file, …  Operations:
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.
CS 180 Problem Solving and Object Oriented Programming Fall 2010 Notes for Week 3: September 6-10, 2010 Aditya Mathur Department of Computer Science Purdue.
Compsci 06/101, Fall What will we do today? l Practice solving problems  Solving problems without a computer  Is this different than solving.
November 2003Bent Thomsen - FIT 6-11 IT – som værktøj Bent Thomsen Institut for Datalogi Aalborg Universitet.
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.
Python – May 11 Briefing Course overview Introduction to the language Lab.
Building Java Programs Primitive Data and Definite Loops.
CompSci 101 Introduction to Computer Science Sept. 9, 2014 Prof. Rodger President Brodhead speech graduation 2010 CompSci 101 Fall
Copyright 2008 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
Compsci 6/101, Spring More on Python, Tools, Compsci 101 l APTs, Assignments, Tools  APT: Algorithmic Problem-solving and Testing  How to get.
CompSci 6 Programming Design and Analysis January 17, 2006 Prof. Rodger.
Compsci 101.2, Fall PFTWeek l Introduce new Python concepts  Control: if, elif, else, for  Data: Strings, Lists Operators on data: slicing,
Compsci 06/101, Fall Vocabulary l What's the Spanish word for 'boy'? 'eat'?  How do you know? l What about the Turkish equivalents?  How do.
Copyright 2010 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
CompSci 101 Introduction to Computer Science January 28, 2016 Prof. Rodger compsci101 spring161.
Compsci 6/101, Spring PFTW: Functions, Control, Python/Tools l How do functions work and why do we use them?  Functions we call (APIs), Functions.
CompSci 101 Introduction to Computer Science January 26, 2016 Prof. Rodger compsci 101, spring
Programming for Interactivity Professor Bill Tomlinson Tuesday & Wednesday 6:00-7:50pm Fall 2005.
CompSci 101 Introduction to Computer Science January 15, 2015 Prof. Rodger 1.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #003 (February 14, 2015)
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.
Quiz 1 A sample quiz 1 is linked to the grading page on the course web site. Everything up to and including this Friday’s lecture except that conditionals.
CompSci 101 Introduction to Computer Science Sept 13, 2016 Prof. Rodger compsci101 fall161.
CompSci 4 Java 1 Apr 2, 2009 Prof. Susan Rodger. Announcements Assignment 7 questions? –Beware having two events that kick in at the same time! –Beware.
Fundamentals of Programming I Overview of Programming
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
Building Java Programs
CompSci 101 Introduction to Computer Science
Primitive Data, Variables, Loops (Maybe)
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
Building Java Programs Chapter 2
CompSci 101 Introduction to Computer Science
PHP Intro/Overview Bird Book pages 1-11,
Building Java Programs
Building Java Programs Chapter 2
CompSci 101 Introduction to Computer Science
CS 200 Primitives and Expressions
Topics Introduction to Value-returning Functions: Generating Random Numbers Writing Your Own Value-Returning Functions The math Module Storing Functions.
Building Java Programs
Java Programming Review 1
Building Java Programs
Building Java Programs
PFtTBSB Files and formats: how to read and store data
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs Chapter 2
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Running & Testing Programs :: Translators
Presentation transcript:

Compsci 101, Fall Plan For The Day (PFTD) l Practice solving problems  Some solved with a computer, some with Python  Differences in solving non-computing problems? l Learning about vocabulary and sentences  We'll work with English and Python l Practice using tools for Duke Compsci courses  Eclipse, APT, ambient, Skulpt, Python-tutor  Sakai, Piazza, Feedback l Reveling in the wonder of thinking and working  How do we know when something works?

Compsci 101, Fall What is an APT? cheeseburger APTcheeseburger APT l Automated/Algorithmic Problem Test  Write one function, 2-30 lines, solve a problem  Tested automagically in Eclipse or the browser  Test test test … Quality of code not a factor in grading l Start simple, build toward more complex  What is a function? A function call?  What is a parameter? Argument?  How do you execute a program? Run is a synonym l Skulpt and Python Tutor Skulpt Python Tutor  See course web pages

Compsci 101, Fall Vocabulary, grammar, rules: Python l Naming  The power of abstraction and parameterization  What is abstraction?  What are parameters? What has them? l Types  What's used in computing? What's used in Python?  Determine names of types in Python l Expressions and operators in Python  Arithmetic: +, -, *, /, %, **, …  Boolean:, and,...  String: +, *, [], [:], [::]

Compsci 101, Fall Variables, Types, Values l Variable is a name associated with "container/stuff"  Assign a value: x = 5  Print value of variable: print x  Use variable in expression: y = x * 55 l String is a types and has a value  Assign: x = "hello"  Print value of variable: print x  Use in expression print len(x ) print x + " world" l There are more types, this is enough to start!

Compsci 101, Fall Types and values in Python l Numbers are important, but not everything is a …  What is a number? In mathematics, in Python, in Java,  Integers, floating-point numbers, complex numbers, … In Python and other languages, integers are smaller/faster, but you don't need to know this now! 1,2,3 compared to , 1.75 compared to 3 + 5i l Strings are sequences of characters, "python.org"  Somewhere these are converted to numbers: 0's and 1's  No real need to know this now. l In Python different things done to numbers/strings

Compsci 101, Fall Expressions, Operators, Types Why is 3+5*4 different than (3+5)*4 ?  Where can you find information about precedence? Why is 5/3 different than 5.0/3 ?  What will happen in Python 3? Accommodate in 2.7? l What happens when operators go bad?  What is "apple" + 3? What is "apple" + "pi"?  What is "apple" * 3? What is "apple" * "pi" ? l What is a variable in Python?  Does it have a name? Does it have a type?

Compsci 101, Fall 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

Compsci 101, Fall Counting words in a file: Python redux name = "/data/poe.txt" ff = open(name) st = ff.read() words = st.split() print "# words in",name, "=",len(words) l What are the names in the code above?  Why are names important? l What are the types in the code above?  How do we get Python to help us answer this question l How do we re-use this code more generally  The power of names! The power of functions!

Compsci 101, Fall Names and Types summarized l There are rules for what a valid name is in Python  In addition there are conventions we will use for names l In code shown we see variables, constants, functions, and methods  This is more vocabulary, talking Python to others?  What are each of those italicized words?  type() and interactive console/interpreter l Types for variables and expressions  We see file, string, list, int, float; later: list, set, and more l Always ask: what's name, what's type, what's value?

Compsci 101, Fall Interlude l Use word-counting code in Eclipse  Python console, type and see  Using names, what is a.py file, user-defined functions  Modules and functions: re-use with minimal re-typing Function is abstraction, parameterization over code Module is abstraction over functions l Python functions and expressions, practicing solving problems  APTs for next week  Gravity, cheeseburger, Bogword  BMI, Heron's formula BMIHeron's formula

Compsci 101, Fall Getting ready to code in Python l We need a programming environment  Eclipse, PyDev, Python, Ambient  Open source or free for academics l We need a computer with an operating system  Installing the suite of tools can be cumbersome  We'll help, when things don't work, start over  l Getting used to the environment can take time  Once you've got it, second nature!  Easy to reuse with a new language (and some new tools)

Compsci 101, Fall Nathan Myhrvold l Who is he?  We invent for fun. Invention is a lot of fun to do. And we also invent for profit. The two are related because the profit actually takes long enough that, if it isn't fun you wouldn't have the time to do it.