-
Book Overview & Buying
-
Table Of Contents
Cracking the Data Science Interview
By :
String operations are very common when working with Python and text data. Therefore, this section will review how to initialize a string, string indexing/slicing, and some common string methods.
Note
We will not review string regular expressions, as this is a large topic with significant depth. Check out Mastering Python Regular Expressions by Victor Romero and Felix L. Luis for more instructions on this topic.
Python allows for string initialization (creation) in several ways. Two ways include single quotes ('') and double quotes (""):
# Single quotes s = 'Hello, World!' print(s) # prints: Hello, World! # Double quotes s = "Hello, World!" print(s) # prints: Hello, World!
Single and double quotes are basically interchangeable. The only difference comes into play when you have a quote mark (single or double) inside a string. For example, one common scenario is...
Change the font size
Change margin width
Change background colour