1 / 8

Thinking about Strings

Thinking about Strings. Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg. What are strings?. Sequences of characters We will often work with sequences of data String is just a specific example

penha
Télécharger la présentation

Thinking about Strings

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. Thinking about Strings Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg

  2. What are strings? • Sequences of characters • We will often work with sequences of data • String is just a specific example • We will see many of the things we do with strings later on with other sequences of data

  3. Sequences of data • Can work with size of sequence • Can work with individual pieces of information in the sequence

  4. Thought Exercise • Suppose I give you a string >>> mesg = “Today is Wednesday” • What is the length of that string?

  5. Thought Exercise >>> mesg = “Today is Wednesday” • mesg[1] • mesg[11] • mesg[-1] • mesg[3:9] • mesg[15:]

  6. Note about Answers >>> msg[3:9] • Answer is ay is • But how do we write this to show spaces? • On answer sheets or tests, be very careful • If I can’t tell that there are spaces, I might take points off

  7. Questions so far?

  8. Let’s talk about the lab • Sequences, indexes, and slicing. • Reversing the Str • Working backwards and appending • Working forwards and prepending • Counting the vowels • Handling both cases • Using functions and handling only one case

More Related