Comp Sci 101 Introduction to Computer Science January

  • Slides: 14
Download presentation
Comp. Sci 101 Introduction to Computer Science January 27, 2015 Prof. Rodger

Comp. Sci 101 Introduction to Computer Science January 27, 2015 Prof. Rodger

Announcements • • Reading, RQ 06 next time Assign 2 due today, Assign 3

Announcements • • Reading, RQ 06 next time Assign 2 due today, Assign 3 out APT 2 is due on Thursday Lab 3 this week • Finish working on APT Pancakes compsci 101 spring 2015 2

APT Pancakes…. (cont) compsci 101 spring 2015 3

APT Pancakes…. (cont) compsci 101 spring 2015 3

Turtles bit. ly/101 S 15 -0127 -01 • Run in eclipse • Make square

Turtles bit. ly/101 S 15 -0127 -01 • Run in eclipse • Make square with different sizes? • Make a rectangle? • Where is the repetition? • New commands: • up(), down(), position(), goto() compsci 101 spring 2015 4

Assignment 3 • Draw a picture compsci 101 spring 2015 5

Assignment 3 • Draw a picture compsci 101 spring 2015 5

Computer Science Alum • • Biology and CS Undergraduate Research - JFLAP Epic Now

Computer Science Alum • • Biology and CS Undergraduate Research - JFLAP Epic Now in Med School at Vanderbilt compsci 101 spring 2015 6

More Computer Science Duke Alums compsci 101 spring 2015 7

More Computer Science Duke Alums compsci 101 spring 2015 7

More on Strings • Strings are indexed starting at 0 • Example: ‘word’ w

More on Strings • Strings are indexed starting at 0 • Example: ‘word’ w o r d 0 1 2 3 • 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. compsci 101 spring 2015 8

Examples phrase = "Duke Blue Devils" print phrase[0] print phrase[-3] print phrase[1: 3] print

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() String fun Crazy import compsci 101 spring 2015 9

Loop over all characters in a String compsci 101 spring 2015 10

Loop over all characters in a String compsci 101 spring 2015 10

Loop over string • Online form: www. bit. ly/101 S 15 -0127 -02 compsci

Loop over string • Online form: www. bit. ly/101 S 15 -0127 -02 compsci 101 spring 2015 11

Loop over all words in a list compsci 101 spring 2015 12

Loop over all words in a list compsci 101 spring 2015 12

Loop over words • Online form: www. bit. ly/101 S 15 -0127 -03 compsci

Loop over words • Online form: www. bit. ly/101 S 15 -0127 -03 compsci 101 spring 2015 13

APT Emphasize bit. ly/101 S 15 -0127 -04 compsci 101 spring 2015 14

APT Emphasize bit. ly/101 S 15 -0127 -04 compsci 101 spring 2015 14