Using the value of data from Exercise 1, write the values of the follow- ing exp
ID: 3727092 • Letter: U
Question
Using the value of data from Exercise 1, write the values of the follow- ing expressions: a data.endswith('i') b “ totally “.join(data.split())
Assume that the variable data refers to the string “Python rules!”. Use a string method from Table 4.2 to perform the following tasks: a Obtain a list of the words in the string. b Convert the string to uppercase. c Locate the position of the string “rules”. d Replace the exclamation point with a question mark
Homework-201805-32-x secure ::: Apps D Plans Miller con M eTextbooks l Rent ar Bu X Booksheif Online: Funda x e Chegg Study Guided S https//boakshalf.vitalsource.com/4/hooks/9781 1 3371 5283/cfi/159!/4/4@0.00:13.3 D Welcome-https ear sokans N Lambda Academyo | Southwestern Caileg D × had to request a cer Mavis Beacon Teac @ Hame Rob Enterc Dawnload the Micro Other bookmark Ch 4: Strings and Te… STRING METHOD WHAT IT DOES Go to Ch 4: Strings and Text Files Returns a copy of s centered within the given number of columns. s.center (width) 224.1: Accessing Characters and Substrings in Strings s.count (sub, start, end]1) Returns the number of non-overlapping occurrences of substring sub in B. Optional arguments start and end are interpreted as n slice notation. 26 4.2: Data Encryption 129 4.3: Strings and Number Systems 36 4.4:String Methods 41 4.5: Text Files Returns True if s ends with sub or False otherwise. s.endswith (sub) ] s.find(sub, start , end] Returns the lowest index in s where substring sub is found. Optional arguments 148 4.6 Case Study: Text Analysis start and end are interpreted as in slice 53 Summary notation 154 Review Questions Returns True if s contains only letters or False otherwise. s.isalpha() 156 Projects s.isdigit) Returns True if s contains only digits or False otherwise. Returns a string that is the concatenation of the strings in the sequence. The separator between elements i Returns a copy of s converted to lowercase. s.join(sequence) S S s.lower() 138 Type here to search ] e 4 w b b Olb_ @ A ^ en8Explanation / Answer
a) data.endswith("i") data is "Python rules!" . The expression will return False because
data does not ends with i
b) "totally".join(data.split())
The answer is Pythontotallyrules!
----------------------------------------------------------
a) list of words from a string
list = s.split(" ") where s is a string
b) Converting a string to uppercase
s = s.upper (s is a string)
c) Locating the position of string rules
pos = data.find("rules")
d)Replacing ! with question mark
data = data.replace("!","?")
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.