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

Slides:



Advertisements
Similar presentations
Chapter 4 Working with Strings. "The Practice of Computing Using Python", Punch & Enbody, Copyright © 2013 Pearson Education, Inc. Sequence of characters.
Advertisements

Introduction to Computers and Programming Lecture 10: For Loops Professor: Evan Korth New York University.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 13 - The Preprocessor Outline 13.1Introduction 13.2The #include Preprocessor Directive 13.3The.
October 4, 2005ICP: Chapter 4: For Loops, Strings, and Tuples 1 Introduction to Computer Programming Chapter 4: For Loops, Strings, and Tuples Michael.
General Programming Introduction to Computing Science and Programming I.
Welcome to IIT and cs115!.
Recursion A method is recursive if it makes a call to itself. A method is recursive if it makes a call to itself. For example: For example: public void.
Strings The Basics. Strings can refer to a string variable as one variable or as many different components (characters) string values are delimited by.
Lab 07: Caesar Cypher Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg.
Lists and Tuples Intro to Computer Science CS1510 Dr. Sarah Diesburg.
PHY 107 – Programming For Science. Announcements  Slides, activities, & solutions always posted to D2L  Note-taking versions before class, for those.
CIT 590 Intro to Programming Lecture 5 – completing lists.
Instructor: Craig Duckett Lecture 08: Thursday, October 22 nd, 2015 Patterns, Order of Evaluation, Concatenation, Substrings, Trim, Position 1 BIT275:
Chapter 4 Working with Strings. "The Practice of Computing Using Python", Punch & Enbody, Copyright © 2013 Pearson Education, Inc. Sequence of characters.
Introduction to Strings Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg 1.
L061 Algorithms, Part 3 of 3 Topics Top down-design Structure charts Reading Sections , 3.3.
More Strings CS303E: Elements of Computers and Programming.
ITEC 109 Lecture 11 While loops. while loops Review Choices –1 st –2 nd to ?th –Last What happens if you only use ifs? Can you have just an else by itself?
Tuples and Dictionaries Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg.
Advanced Strings Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg 1.
Midterm Review Important control structures Functions Loops Conditionals Important things to review Binary Boolean operators (and, or, not) Libraries (import.
Dictionaries Intro to Computer Science CS 1510 Dr. Sarah Diesburg.
CSC Programming for Science Lecture 27: Arrays as Parameters, Searching, & Sorting.
CSC 4630 Meeting 17 March 21, Exam/Quiz Schedule Due to ice, travel, research and other commitments that we all have: –Quiz 2, scheduled for Monday.
LECTURE 5 Strings. STRINGS We’ve already introduced the string data type a few lectures ago. Strings are subtypes of the sequence data type. Strings are.
Winter 2016CISC101 - Prof. McLeod1 CISC101 Reminders Quiz 3 this week – last section on Friday. Assignment 4 is posted. Data mining: –Designing functions.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Strings in Python String Methods. String methods You do not have to include the string library to use these! Since strings are objects, you use the dot.
Introduction to programming in java
Introduction to Computing Science and Programming I
Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg
Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg
Intro to Computer Science CS1510 Dr. Sarah Diesburg
CMSC201 Computer Science I for Majors Lecture 27 – Final Exam Review
Strings Part 1 Taken from notes by Dr. Neil Moore
Week 6 Discussion Word Cloud.
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Introduction to Strings
Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg
Basic Python Collective variables (sequences) Lists (arrays)
Topics Introduction to File Input and Output
Lists – Indexing and Sorting
Intro to Computer Science CS 1510 Dr. Sarah Diesburg
String Encodings and Penny Math
Intro to Computer Science CS1510
Thinking about Strings
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg
Intro to Computer Science CS1510 Dr. Sarah Diesburg
CMSC201 Computer Science I for Majors Lecture 25 – Final Exam Review
More on Functions (Part 2)
Lists – Indexing and Sorting
Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Introduction to Computer Science
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg
Introduction to Strings
Lists – Indexing and Sorting
String Encodings and Penny Math
Python Strings.
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Types, Truth, and Expressions
Exam Prep.
Topics Introduction to File Input and Output
Introduction to Strings
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Strings Taken from notes by Dr. Neil Moore & Dr. Debby Keen
Presentation transcript:

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

Topics for today Information on the exams Questions remaining from Tuesday’s Lab? Several examples from your book Some string formatting examples Split()

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

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

Exam Information Tuesday, October 15  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)

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!! 6

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 7

Questions about Tuesday’s Lab Did you understand the explanations I made on both the string-based and math-based solutions? Remaining issues?

Questions over PA05? 9

Anything you want me to go over? 10

String Wrap-Up Find a Letter Enumerate Split Palindromes

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

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

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)

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)

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.

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

Palindromes and the Rules A palindrome is a string that prints the same forward and backwards Same implies that:  case does not matter  punctuation is ignored “Madam I’m Adam” is thus a palindrome

Lower Case and Punctuation Every letter is converted using the lower method Import string, brings in a series of predefined sequences (string.digits, string.punctuation, string.whitespace) We remove all non-wanted characters with the replace method. First arg is what to replace, the second the replacement.

Part 1 of Palindrome # first part import string originalString = input('Input a string:') modifiedStr = originalString.lower() badChars = string.whitespace + string.punctuation for char in modifiedStr: if char in badChars: # remove bad modifiedStr = modifiedStr.replace(char,'')

Part 1 of Palindrome # second part if modifiedStr == modifiedStr[::-1]: # palindrome ? print( 'The original string is: {}\n\ the modified string is: {}\n\ the reversal is: {}\n\ The string is a palindrome'.format( originalString, modifiedStr, modifiedStr[::-1])) else: # similar printing for not a palindrome