CompSci 6 Introduction to Computer Science September 13, 2011 Prof. Rodger.

Slides:



Advertisements
Similar presentations
CompSci 101 Introduction to Computer Science January 22, 2015 Prof. Rodger compsci101 spring151.
Advertisements

Week 8 Arrays Part 2 String & Pointer
CompSci 101 Introduction to Computer Science February 3, 2015 Prof. Rodger Lecture given by Elizabeth Dowd.
CompSci 101 Introduction to Computer Science Feb 26, 2015 Prof. Rodger.
1 9/29/06CS150 Introduction to Computer Science 1 Loops Section Page 255.
CMPT 120 Lists and Strings Summer 2012 Instructor: Hassan Khosravi.
19/5/2015CS150 Introduction to Computer Science 1 Announcements  1st Assignment due next Monday, Sep 15, 2003  1st Exam next Friday, Sep 19, 2003  1st.
CompSci 101 Introduction to Computer Science January 20, 2015 Prof. Rodger compsci 101, spring
Nonvisual Arrays and Recursion by Chris Brown under Prof. Susan Rodger Duke University June 2012.
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 Introduction to Computer Science November 1, 2011 Prof. Rodger.
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.
September 26, 2011 Sorting and Searching Lists. Agenda Review quiz #3 Team assignment #1 due tonight  One per team Arcade game Searching  Linear  Binary.
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 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.
Python Programing: An Introduction to Computer Science
CompSci 101 Introduction to Computer Science February 4, 2016 Prof. Rodger compsci101 spring161.
CompSci 6 Introduction to Computer Science Sept. 20, 2011 Prof. Rodger CompSci 6 Fall
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 4 Chap 10 November 4, 2010 Prof. Susan Rodger.
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.
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 101 Introduction to Computer Science April 7, 2015 Prof. Rodger.
String and Lists Dr. José M. Reyes Álamo. 2 Outline What is a string String operations Traversing strings String slices What is a list Traversing a list.
CompSci 4 Java 4 Apr 14, 2009 Prof. Susan Rodger.
CompSci 101 Introduction to Computer Science March 8, 2016 Prof. Rodger.
CompSci 101 Introduction to Computer Science March 1, 2016 Prof. Rodger.
CompSci 101 Introduction to Computer Science February 5, 2015 Prof. Rodger Lecture given by Elizabeth Dowd compsci101 spring151.
CSC 108H: Introduction to Computer Programming Summer 2011 Marek Janicki.
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
CSC 108H: Introduction to Computer Programming
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
Intro to Computer Science CS1510 Dr. Sarah Diesburg
CompSci 101 Introduction to Computer Science
Introduction to Computer Science
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
ACCOUNTING II Chapter 13 Assignment Sheet
Intro to Computer Science CS1510 Dr. Sarah Diesburg
CompSci 101 Introduction to Computer Science
CS1110 Today: collections.
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Intro to Computer Science CS1510 Dr. Sarah Diesburg
CompSci 101 Introduction to Computer Science
Introduction to Computer Science
Presentation transcript:

CompSci 6 Introduction to Computer Science September 13, 2011 Prof. Rodger

Announcements Read for next time –Chapter 4 (pages 55-61) (note: we will work with images a different way) –Chapter 5 Assignment 2 out - APTs Reading Quiz on Blackboard –Due before class next time

More on Strings Strings are indexed starting at 0 Example: ‘word’ Use [num] – to refer to a particular character in word Use [x:y] to refer to a slice of the string starting at position x and up to but not including position y. Can leave out x or y. w or d

Examples phrase = "Duke Blue Devils" print phrase[0] print phrase[-3] print phrase[1:3] print phrase[5:10] + phrase[:4] print (phrase[phrase.find('ev'):]).upper()

APTs An APT is one a system we have setup to let you focus on solving one method. Similar to javaBat Snarf the APT, test it until you get all green Run in Eclipse Solve some APTs now

Lists A list is a collection of objects scores = [99, 78, 91, 84] allAboutMe = [“Mo”,25, “ ”] club=[‘Mo’,‘Jo’,‘Po’, ‘Flo’, ‘Bo’] Lists are mutable – use [num] to change a value Lists are indexed starting at 0, or -1 from the end Functions: max, min, len, sum Slice lists [:]

List Examples scores = [10, 9, 10, 8] print scores scores[2] = 5 print scores print max(scores) print len(scores) print sum(scores) print scores[1:] print scores[1]

List before/after modification score = [10,8,10,9] score [2] =

Processing List Items Process all the items in a list, one item at a time Format: for variable in list: block Example: sum = 0 nums = [6, 7, 3, 1, 2] for value in nums: sum = sum + value print sum

Copying vs aliasing names = [‘jo’, ‘mo’, ‘bo’] club = names team = names[:] names[1] = ‘flo’ print names print club print team