Lesson 7. Introducing string objects: sequences of characters

 

After reading lesson 7, you’ll be able to

  • Understand what string objects are
  • See what values a string object can have
  • Do some basic operations using string objects

Working with sequences of characters is common. These sequences are known as strings, and you can store any sequence of characters inside a string object: your name, your phone number, your address including the new lines, and so on. Storing information in a string format is useful. You can do many operations after you have data represented in a string. For example, if you and a friend are both doing research for a project, you can take notes on separate concepts and then combine your findings. If you’re writing an essay and discover that you overused a word, you can remove all instances of that word or replace some instances with another word. If you discover that you accidentally had Caps Lock on, you can convert the entire text to lowercase instead of rewriting.

Consider this

Look at your keyboard. Pick out 10 characters and write them down. String them together in any order. Now try to string them in some combination to form words.

Answer:

  • hjklasdfqw
  • shawl or hi or flaw

7.1. Strings as sequences of characters

 
 

7.2. Basic operations on strings

 
 

7.3. Other operations on string objects

 
 

Summary

 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage