Download presentation
Presentation is loading. Please wait.
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 Friday” What is the length of that string?
5
Thought Exercise >>> mesg = “Today is Friday” mesg[1]
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 methods and handling only one case
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.