Chapter 4 - Summary

Chapter 4 included the following concepts from computing.

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".
  • input - The input function returns a string from the user. It can also print out a message to the user, called a prompt.
  • 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".
Next Section - Chapter 4 Exercises