CompSci 6 Introduction to Computer Science September 27, 2011 Prof. Rodger CompSci 6 Fall 20111.

Slides:



Advertisements
Similar presentations
CompSci 101 Introduction to Computer Science February 3, 2015 Prof. Rodger Lecture given by Elizabeth Dowd.
Advertisements

CompSci 101 Introduction to Computer Science Feb 26, 2015 Prof. Rodger.
Announcements DS-533 Fall Week 1: August 25 Read: –Business Forecasting Chapter 2 Do problems: –3, 5, 7, 9, 12, Hand-in assignments –4, 8, 14.
CompSci 101 Introduction to Computer Science January 13, 2015 Prof. Rodger compsci 101 spring
1 CSC 221: Introduction to Programming Fall 2012 course overview  What did you set out to learn?  What did you actually learn?  Where do you go from.
CompSci 101 Introduction to Computer Science January 20, 2015 Prof. Rodger compsci 101, spring
Unit 5 Spreadsheets 5.08 Templates. Introduction In Word we discussed templates and how they relate to word processing. In Excel templates are very similar.
Introduction. 2COMPSCI Computer Science Fundamentals.
CompSci 6 Introduction to Computer Science October 20, 2011 Prof. Rodger.
CompSci 101 Introduction to Computer Science September 23, 2014 Prof. Rodger.
CompSci 101 Introduction to Computer Science Sept. 9, 2014 Prof. Rodger President Brodhead speech graduation 2010 CompSci 101 Fall
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 Introduction to Computer Science November 1, 2011 Prof. Rodger.
More Functions with Return Values CS303E: Elements of Computers and Programming.
CompSci 6 Programming Design and Analysis January 17, 2006 Prof. Rodger.
CompSci 6 Introduction to Computer Science Sept 29, 2011 Prof. Rodger “All your troubles are due to those ‘ifs’,” declared the Wizard. If you were not.
CompSci 6 Introduction to Computer Science November 8, 2011 Prof. Rodger.
CompSci 101 Introduction to Computer Science November 18, 2014 Prof. Rodger.
CompSci 101 Introduction to Computer Science March 3, 2015 Prof. Rodger compsci101 spring151.
CompSci 6 Introduction to Computer Science September 13, 2011 Prof. Rodger.
CompSci 101 Introduction to Computer Science March 31, 2015 Prof. Rodger Thanks to Elizabeth Dowd for giving this lecture Review for exam.
CompSci 101 Introduction to Computer Science February 10, 2015 Prof. Rodger “All your troubles are due to those ‘ifs’,” declared the Wizard. If you were.
Compsci 101.2, Fall Plan for October 22 l Images, tuples, RGB color model  Image processing by understanding API  Image processing with tuples.
CompSci 101 Introduction to Computer Science January 28, 2016 Prof. Rodger compsci101 spring161.
CompSci 101 Introduction to Computer Science February 4, 2016 Prof. Rodger compsci101 spring161.
CompSci 101 Introduction to Computer Science Feb 24, 2015 Prof. Rodger.
CompSci 101 Introduction to Computer Science February 11, 2016 Prof. Rodger.
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 101 Introduction to Computer Science March 17, 2015 Prof. Rodger compsci 101, spring
CompSci 101 Introduction to Computer Science February 25, 2016 Prof. Rodger compsci101 spring20161.
CompSci 101 Introduction to Computer Science January 15, 2015 Prof. Rodger 1.
Today… Modularity, or Writing Functions. Winter 2016CISC101 - Prof. McLeod1.
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 101 Introduction to Computer Science April 7, 2015 Prof. Rodger.
CompSci 101 Introduction to Computer Science March 24, 2016 Prof. Rodger compsci 101, spring
CompSci 101 Introduction to Computer Science March 8, 2016 Prof. Rodger.
CompSci 101 Introduction to Computer Science April 14, 2016 Prof. Rodger Lecture today by Sriram Vepuri.
CompSci 101 Introduction to Computer Science March 1, 2016 Prof. Rodger.
CompSci 101 Introduction to Computer Science April 14, 2016 Prof. Rodger compsci101 spring161.
CompSci 101 Introduction to Computer Science March 29, 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 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.
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
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 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 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 Computer Science
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
Quiz: Computational Thinking
CompSci 101 Introduction to Computer Science
Presentation transcript:

CompSci 6 Introduction to Computer Science September 27, 2011 Prof. Rodger CompSci 6 Fall 20111

Announcements No Reading for next time No Reading Quiz for next time Apt-02 due tonight, Assignment 3 due Thursday Exam next Tuesday Work the practice exam before Thursday’s class. Will go over next class. CompSci 6 Fall 20112

List Comprehension review Take advantage of patterns, make a new list based on per element calculations of another list Format: [ for in ] Format with filtering: [ for in if ] 3

List Comprehensions from last time [j+1 for j in range(20) if j%3==0] CompSci 6 Fall 20114

List Comprehensions from last time [j+1 for j in range(20) if j%3==0] [0, 1, 2, … 19] CompSci 6 Fall 20115

List Comprehensions from last time [j+1 for j in range(20) if j%3==0] [0, 1, 2, … 19] [1, 2, 3, …, 20] this is j+1 CompSci 6 Fall 20116

List Comprehensions from last time [j+1 for j in range(20) if j%3==0] [0, 1, 2, … 19] [1, 2, 3, …, 20] this is j+1 [1,4,7,10,13,16,19] j+1 if j%3==0 CompSci 6 Fall 20117

List Comprehensions from last time [i*2 for i in [j+1 for j in range(20) if j%3==0] if i*i > 19] CompSci 6 Fall 20118

List Comprehensions from last time [i*2 for i in [j+1 for j in range(20) if j%3==0] if i*i > 19] [i*2 for i in [1,4,7,10,…,19] if i*i > 19] CompSci 6 Fall 20119

List Comprehensions from last time [i*2 for i in [j+1 for j in range(20) if j%3==0] if i*i > 19] [i*2 for i in [1,4,7,10,…,19] if i*i > 19] [[2,8,14,20,26,32,38] if i*i > 19] [14, 20, 26, 32, 38] <- answer after filtering 10

List Comprehension examples List comprehension creates a new list. Use wherever you need a new list. Can use list comprehension to create a list to return From Uppity.py – words is list of words def uppify_list(words): return [w.upper() for w in words] Classwork problem 1 Show additional examples CompSci 6 Fall

Problem: complete program Problem: Given a file of words, for each line print out only those words that are longer than 4, thus removing all the “short” words. Example: Where are all the wild things? becomes Where things? CompSci 6 Fall

Tasks in solving this problem First understand the code given Then fill in missing code (TODO) –In Eclipse, “Window”, “Show view”, “Tasks” Test it with data file you create –May need to create data folder Where is the fence post problem? Debugging – what do you do when it doesn’t work? CompSci 6 Fall

Fence post problem How many posts, how many supports between all those posts? Build fence: for post in posts: fence = fence + post + supports

Passing Functions as Parameters def upperWord(word): return word.upper() def argWord(word): return word + “arg” def transformWord(func, word): return func(word) print transformWord(upperWord, “train”) print transformWord(argWord, “truck”) CompSci 6 Fall

Assignment 3 Transform Look over assignment What parts are similar to what we just did? Passing functions as parameters What are the imports? Has file browser for you import InputGUI as Input To input from Console change line to: import InputConsole as Input CompSci 6 Fall