4.5. Chapter 4 - Summary

Chapter 4 included the following concepts from computing.

4.5.1. Summary of String Functions

Chapter 4 also included the following string functions.

  • append - You can add two strings together using the + symbol. This is also called concatenate. The result of "Happy" + " Birthday" is "Happy Birthday".

  • find - The find function takes a string as input and returns the index of the first occurence of that string in the string the function is called on. The code "goodbye".find('bye') returns 4.

  • len - The len function that can take a string as input and returns the number of characters in the string including any spaces. For example len("Hi there") will return 8.

  • lower - The lower string function returns a new string with only lowercase letters. For example "ALL CAPS".lower() returns "all caps".

  • slice - You can get part of a string which is also called a substring using [start] or [start:end] which will return a substring of the current string starting at the given start position and if an end position is given ending at the character before the end position. For example "out"[1] will return "u" and "otter"[2:5] returns "ter".


This is the end of chapter 4. We would love it if you could give us some feedback on this chapter at https://www.surveymonkey.com/r/ch4-student-fb. You might want to open this link in a new tab to make it easier for you to return to your place in this ebook.

You have attempted of activities on this page