Presentation is loading. Please wait.

Presentation is loading. Please wait.

CompSci 101 Introduction to Computer Science March 31, 2015 Prof. Rodger Thanks to Elizabeth Dowd for giving this lecture Review for exam.

Similar presentations


Presentation on theme: "CompSci 101 Introduction to Computer Science March 31, 2015 Prof. Rodger Thanks to Elizabeth Dowd for giving this lecture Review for exam."— Presentation transcript:

1 CompSci 101 Introduction to Computer Science March 31, 2015 Prof. Rodger Thanks to Elizabeth Dowd for giving this lecture Review for exam

2 Announcements Exam 2 is Thursday Assignment 7 is out APT 8 is due today Review Session with Prof. Rodger –Wed. 5:30pm, LSRC B101 Finish lecture notes from last time

3 Snarky Hangman Version of Hangman that is hard to win. Program keeps changing secret word to make it hard to guess! User never knows! Once a letter is chosen and shown in a location, program picks from words that only have that letter in that location Program smart to pick from largest group of words available

4 Snarky Hangman - Dictionary Builds a dictionary of categories Start with list of words of correct size Repeat –User picks a letter –Make dictionary of categories based on letter –New list of words is largest category Matched letters Letters guessed by not chosen List shrinks in size each time

5 Snarky Hangman Example Possible scenerio after several rounds You currently have a list of all words with u the second letter. From that build a dictionary of list of words with no c and with c in different places (show count of number of words in each list): Choose “no c”, most words, 21 Only 2 words of this type Only 8 words of this type

6 Exam logistics Only need a pen or pencil No scratch paper See the reference sheet of Python information you will get with the test (see resources page) Closed book, closed notes, closed neighbor Covers lecture, lab and assigned reading Have put old quizzes back up as quiz review –This is NOT for a grade, for studying only CompSci 101 Spring 20156

7 Understand old and new topics Old topics: if, for, while, lists, strings list comprehension, enumerate Files – write code - Will give you a file already opened and ready for reading Sets, Dictionaries – write code – create and use Understand items on Python review sheet on resources page HAVE NOT COVERED TOPICS – regular expressions or recursion CompSci 101 Spring 20157

8 The best way to study Write code on paper! Resources page has old tests and solutions –Try writing code, then look at solutions Rewrite an APT Rewrite code we did in lecture Rewrite code we did in classwork or lab CompSci 101 Spring 20158

9 Think about how parameters work Look at variables before passed to a method What happens to them after they are passed? Can the parameter and argument have the same name?

10

11 number is 5, school is duke In testone, num is 4, s is Hello After call to testone, number is 5, school is duke OUTPUT

12 Parameter and Argument have the same name

13 OUTPUT num is 2, s is cat In testone, num is 4, s is Hello After call to testone, num is 2, s is cat

14

15 OUTPUT nums is [4, 3, 8, 5] In testtwo, lista is [4, 3, 8, 5, 6] After call to testtwo, nums is [4, 3, 8, 5, 6]

16 Parameter and Argument have the same name

17 OUTPUT lista is [4, 3, 8, 5] In testtwo, lista is [4, 3, 8, 5, 6] After call to testtwo, lista is [4, 3, 8, 5, 6]

18

19 OUTPUT lista is (4, 5, 2) In testthree, lista is (4, 5, 2) In testthree, lista is (7, 1, 3) after call to testthree, lista is (4, 5, 2)

20 Parameter and Argument have the same name

21 OUTPUT lista is [(4, 5, 2), (3, 2), (3, 4)] In testfour, lista is [(4, 5, 2), (3, 2), (3, 4)] In testfour, lista is [(4, 5, 2), (4, 3), (3, 4)] after call to testfour, lista is [(4, 5, 2), (4, 3), (3, 4)]

22

23 OUTPUT mylist is [(4, 5, 2), (3, 2), (3, 4)] In testfour, lista is [(4, 5, 2), (3, 2), (3, 4)] In testfour, lista is [(4, 5, 2), (4, 3), (3, 4)] after call to testfour, mylist is [(4, 5, 2), (4, 3), (3, 4)]

24

25 OUTPUT myset is set([2, 4, 5]) In testfive, seta is set([2, 4, 5]) In testfive, seta is set([2, 3, 4, 5]) after call to testfive, myset is set([2, 3, 4, 5])

26

27 OUTPUT myset is set([(3, 2), (5, 2, 1), (4, 3)]) In testsix, seta is set([(3, 2), (5, 2, 1), (4, 3)]) In testsix, seta is set([(5, 8), (3, 2), (5, 2, 1), (4, 3)]) after call to testsix, myset is set([(5, 8), (3, 2), (5, 2, 1), (4, 3)])

28 Now go over Test Practice problems


Download ppt "CompSci 101 Introduction to Computer Science March 31, 2015 Prof. Rodger Thanks to Elizabeth Dowd for giving this lecture Review for exam."

Similar presentations


Ads by Google