70 likes | 75 Views
Discover the basics of strings - sequences of characters - and learn how they can be manipulated and analyzed. Explore various operations on strings and understand their applications to other types of data sequences.
E N D
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 • We will see many of the things we do with strings later on with other sequences of data
Sequences of data • Can work with size of sequence • Can work with individual pieces of information in the sequence
Thought Exercise • Suppose I give you a string >>> mesg = “Today is Friday” • What is the length of that string?
Thought Exercise >>> mesg = “Today is Friday” • mesg[1] • mesg[11] • mesg[-1] • mesg[3:9] • mesg[10:] • mesg[10:37]
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