Chapter 3: Strings (Solutions to Even-Numbered Exercises)

Question 2

>>> "They'll hibernate during the winter."
"They'll hibernate during the winter."
>>> '"Absolutely not," he said.'
'"Absolutely not," he said.'
>>> '''"He said, 'Absolutely not'", recalled Mel.'''
'"He said, \'Absolutely not\'", recalled Mel.'
>>> 'hydrogen sulfide'
'hydrogen sulfide'
>>> 'left\right'
'left\right'

Question 4

>>> len('')
0

Question 6

>>> 'g' == "g"
True
>>> 'g' == 'G'
False
>>> 'a' >= 'b'
False
>>> 'ant' < 'abc'
False
>>> 'ant' > 'Ant'
True
>>> 'ant' > 'Abc'
True
>>> 'ant' < 'anti'
True

Question 8

Because concatenation isn't sensible (or even defined) for integers and other types of data. If left is "abc" and right is the number 45.6, putting left and right side by side wouldn't make any sense.