Chapter 6: Manipulating Strings

Ace your homework & exams now with Quizwiz!

The partition( ) method separates a string into a tuple with __________ items.

3

A(n) completely ignores all escape characters and prints any backslash that appears in the string. A. raw string B. multiline comment C. escape character D. string literal

A. raw string (p. 131)

Which of the following strings WILL NOT work? A. "That is Alice's cat." B. 'That is Alice's cat.' C. 'That is Alice\'s cat.' D. All will work. E. None will work.

B. 'That is Alice's cat.'

A(n) lets you use characters that are otherwise impossible to put into a string. A. character actors B. string literal C. escape character D. printable character

C. escape character (p. 130-131)

To use a single quote within a string literal, the string literal needs to begin and end with __________.

Double quotes (p. 130)

True or False: The isupper() method will return a Boolean "True" value if the string has at least one letter and all the letters are lowercase.

False (p. 135)

String literals in Python usually begin and end with a __________.

Single quote (p. 130)

__________ __________ uses the %s operator inside a string literal as a marker that is replaced with another value.

String interpolation (p. 134)

True or False: Text is one of the most common forms of data your programs will handle.

True (p. 129)

What escape character results in a newline (line break)?

\n

What escape character results in a tab?

\t

Consider the following code: alphabet= 'abcabcabc' What code would split the string in variable alphabet into the list [ab, ab, ab]

alphabet.split(c)

When using the "in" or "not in" operators with strings, the return value will be Boolean values of __________ or __________.

"True" or "False" (p. 133)

A __________ can be passed to the split( ) method to specify where to split the string.

delimiter

An f string places an _________ before the beginning of the string literal (i.e. outside the quotes) to make the string a f string.

f

__________ are similar to string interpolation except they use braces instead of %s.

f-strings

What code would convert the reference value of string variable "greeting"to all lower case?

greeting = greeting.lower()

What code would convert the reference value of string variable "greeting" to all upper case?

greeting = greeting.upper()

What code would slice out the word Hello from the following string literal and assign it to variable "greeting"? hello = 'Hello, World!'

greeting = hello[0:5]

The __________ symbol is used to indicate the beginning of a single line comment that will not be read by the compiler in Python.

hashtag # (p. 132)

The __________method is useful when you have a list of strings that need to be joined together into a single value.

join( ) (p. 138)

split( ) is called on string value, and returns a __________ value.

list (p. 139)

What code would determine if the word 'World" is in the string variable hello = 'Hello, World!' and print the result to the screen.

print('World' in hello)

What code would print the value of string variable "greeting" to the screen in all lower case without changing the value of the reference?

print(greeting.lower())

What code would print the value of string variable "greeting" to the screen in all upper case without changing the value of the reference?

print(greeting.upper())

Placing an _________ before the beginning of the string literal (i.e. outside the quotes) makes the string a raw string.

r

join( ) is called on string value, and passed a list value, and returns a __________ value.

string (p. 139)

The __________ method with remove white space characters from the beginning and end of a string when called on that string.

strip( ) (p.142)

A multiline string in Python begins and ends with either __________ single quotes or double quotes.

three (p.131)

__________ are used to make multiline comments that will not be read by the compiler in Python.

triple double quotes (p. 132)

partition( ) is called on string value, and passed a string, and returns a __________ value.

tuple (p. 140)


Related study sets

POBF- Unit 5 pt.2 Final Exam Review

View Set

Speech Comm Chp 16-17 Study Guide

View Set

Pharmacology 306: Test 1 Kahoot Questions

View Set

Fundamental Information Security Chapter 11: Malicious Code and Activity

View Set

CHAPTER 9- TEACHING AND COUNSELING

View Set

CHAP 11: Crustal Deformation + Mountain Building *

View Set

Course Point - Chapter 13: Outcome Identification & Planning

View Set