1 / 15

Exam Prep and Wrap-Up

Get information about the upcoming exams, examples from the book, and learn about string formatting. Tips and advice for studying and reviewing the material.

claskey
Download Presentation

Exam Prep and Wrap-Up

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Exam Prep and Wrap-Up Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg

  2. Topics for today • Information on the exams • Several examples from your book • Some string formatting examples

  3. Exam Information • Two exams next week • Focuses on chapters 0-4 • Includes material from the lectures and from the readings.

  4. Exam Information • Monday • In class, written exam • Mixture of multiple choice, short answer, and essay. • 100 points • Closed book, closed notes

  5. Exam Information • Tuesday • In lab, programming exam • Five small scripts • 125 points (25 points each) • Closed book, MOSTLY closed notes • One page (one sided) of handwritten notes • May also use the built in Python documentation (really not helpful if you haven’t used it before then)

  6. Advice for the Tests • These things can make the difference of whether you pass or fail this class when studying • Go through each class days notes and example programs on the website • Practice coding over and over by going through your labs!!! This is the only way to really learn. • Review vocabulary and concepts by reading the book!!

  7. Again… • The only way you can become comfortable with a toolset is to practice • Understanding what a power drill does will not help you much if you don’t practice using it • It’s the same for code • Practicing coding will make you more familiar with the coding structures necessary to code more quickly • Patterns will emerge, it will become easier

  8. Review Wrap-Up • Find a Letter • Error Checking • Nested Loops

  9. 4.1 Find a Letter river = 'Mississippi' target = input('Input character to find: ') found = False for index in range(len(river)): #for each index if river[index] == target: #check print( "Letter found at index: ", index ) found = True break # stop searching if (found == False) print( 'Letter',target,'not found in',river)

  10. Examples

  11. Enumerate Function • The enumerate function prints out two values: the index of an element and the element itself • Can use it to iterate through both the index and element simultaneously, doing dual assignment

  12. 4.2-4.3 Enumeration # print first occurrence river = 'Mississippi' target = input('Input character to find: ') for index,letter in enumerate(river): if letter== target: #check print ("Letter found at index: ", index) break # stop searching else: print( 'Letter',target,'not found in',river)

  13. 4.2-4.3 Enumeration # print all occurrences river = 'Mississippi' target = input('Input character to find: ') for index,letter in enumerate(river): if letter== target: #check print ("Letter found at index: ", index ) # break # stop else: print( 'Letter',target,'not found in',river)

  14. Split Function • The split function will take a string and break it into multiple new string parts depending on what the argument character is. • By default, if no argument is provided, split is on any whitespace character (tab, blank, etc.) • You can assign the pieces with multiple assignment if you know how many pieces are yielded.

  15. Reorder a Name origName = ‘John Marwood Cleese’ first,mid,last = origName.split() name = last + ‘, ‘ + first + ‘ ‘ + mid print (name)

More Related