Comp Sci 101 Introduction to Computer Science January

  • Slides: 23
Download presentation
Comp. Sci 101 Introduction to Computer Science January 22, 2015 Prof. Rodger compsci 101

Comp. Sci 101 Introduction to Computer Science January 22, 2015 Prof. Rodger compsci 101 spring 15 1

Announcements • Reading, RQ 05 for next time • Assignment 2 due Tues •

Announcements • Reading, RQ 05 for next time • Assignment 2 due Tues • APT 1 is due today, APT 2 out compsci 101 spring 15 2

REMINDER DO NOT SIT IN THE LAST TWO ROWS! Come forward and sit beside

REMINDER DO NOT SIT IN THE LAST TWO ROWS! Come forward and sit beside someone you haven’t met compsci 101 spring 15 3

How many ways can I run Python in this course? • Eclipse – Complete

How many ways can I run Python in this course? • Eclipse – Complete program – Console – APT • Online textbook – Beware Python 3 (‘/’ (2. 7) vs ‘//’ (3) ) • Python Tutor compsci 101 spring 15 4

How to get Help in this class • • Piazza Consulting hours (Sunday-Thursday nights)

How to get Help in this class • • Piazza Consulting hours (Sunday-Thursday nights) Office hours (Prof, Tas) What happens if my laptop breaks and I can’t use my eclipse? Do I stop programming? – Clusters, Python Tutor, websubmit, borrow • What happens if you send Prof. Rodger an email? • 35 support people vs. 1 person, may take awhile to answer compsci 101 spring 15 5

Submitting an APT or Assignment • Use Ambient – submit – Submit History –

Submitting an APT or Assignment • Use Ambient – submit – Submit History – files submitted should be listed! – Alternative – use web submit – Tuesday midnight means Tuesday 11: 59 pm + 1 minute – If you can’t submit on your computer, copy your file to another computer (Link? ) and submit with websubmit on that computer compsci 101 spring 15 6

Why is this person so important to this course? • Have you donated yet?

Why is this person so important to this course? • Have you donated yet? compsci 101 spring 15 7

Top 10 list for surving in Comp. Sci 101 10. Ask questions 9. Eat

Top 10 list for surving in Comp. Sci 101 10. Ask questions 9. Eat lots of pizza 8. Learn how to spell Rodger 7. Read the book 6. Do the reading quizzes compsci 101 spring 15 8

Top 10 list (cont) 5. Check Piazza every day 4. Visit your prof in

Top 10 list (cont) 5. Check Piazza every day 4. Visit your prof in her office 3. Learn how to debug your programs 2. Seek help (one hour rule!) 1. Start programming assignments early compsci 101 spring 15 9

Algorithm • Describe in words how to solve a problem • Like a recipe,

Algorithm • Describe in words how to solve a problem • Like a recipe, must be detailed and precice compsci 101 spring 15 10

Whole Genome Shotgun with words bit. ly/101 S 15 -0122 -01 • Creation algorithm

Whole Genome Shotgun with words bit. ly/101 S 15 -0122 -01 • Creation algorithm olve problems. ratively, create, compsci 101 we get to work colla vely, create, and s. In compsci 1 y, create, and s e get to work collabo … – Take a phrase – Replicate it four times – Chop into "chunks" • 15 -22 characters • Figure out the original phrase • Describe the algorithm to recreate original phrase? compsci 101 spring 15 11

Review Functions www. bit. ly/101 S 15 -0122 -02 compsci 101 spring 15 12

Review Functions www. bit. ly/101 S 15 -0122 -02 compsci 101 spring 15 12

Use Python Tutor • Debug/trace your code • Doesn’t work with input files compsci

Use Python Tutor • Debug/trace your code • Doesn’t work with input files compsci 101 spring 15 13

Assignment 2 • How to start? • Where does import go? • Student work?

Assignment 2 • How to start? • Where does import go? • Student work? compsci 101 spring 15 14

Solve an APT - Pancakes bit. ly/101 S 15 -0122 -03 compsci 101 spring

Solve an APT - Pancakes bit. ly/101 S 15 -0122 -03 compsci 101 spring 15 15

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 15 16

More Computer Science Duke Alums compsci 101 spring 15 17

More Computer Science Duke Alums compsci 101 spring 15 17

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 15 18

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 15 19

Loop over all characters in a String compsci 101 spring 15 20

Loop over all characters in a String compsci 101 spring 15 20

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

Loop over string • Online form: www. bit. ly/101 S 15 -0122 -04 compsci 101 spring 15 21

Loop over all words in a list compsci 101 spring 15 22

Loop over all words in a list compsci 101 spring 15 22

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

Loop over words • Online form: www. bit. ly/101 S 15 -0122 -05 compsci 101 spring 15 23