MyProgrammingLab Starting Out With Python Ch.8

7 September 2022
4.7 (114 reviews)
19 test answers

Unlock all answers in this set

Unlock answers (15)
question
Write an expression whose value is the character at index 3 of the str associated with s.
answer
s[3]
question
Write an expression whose value is the last character in the str associated with s.
answer
s[-1]
question
Write an expression whose value is the str that consists of the second to last character of the str associated with s.
answer
s[-2]
question
Write an expression whose value is the str that consists of the third to last character of the str associated with s
answer
s[-3]
question
Write an expression that is the concatenation of the strings "Hello" and "World".
answer
'Hello'+'World'
question
Given a String variable address, write a String expression consisting of the string "http://" concatenated with the variable's String value. So, if the variable refers to "www.turingscraft.com", the value of the expression would be "http://www.turingscraft.com".
answer
'http://'+address
question
Write an expression that concatenates the String variable suffix onto the end of the String variable prefix .
answer
prefix+suffix
question
Write an expression that is the concatenation of the str associated with s1 and that associated with the str s2.
answer
s1+s2
question
Given a variable word that has been assigned a string value, write a string expression that parenthesizes the value of word. So, if word contains "sadly", the value of the expression would be the string "(sadly)"
answer
"(" + word + ")"
question
Write an expression whose value is the concatenation of the three str values associated with name1, name2, and name3, separated by commas. So if name1, name2, and name3, were (respectively) "Neville", "Dean", and "Seamus", your expression's value would be "Neville,Dean,Seamus".
answer
name1+','+name2+','+name3
question
Write an expression whose value is the str that consists of the first four characters of the str associated with s.
answer
str=s[:4]
question
Write an expression whose value is the str that consists of the second through fifth characters of the str associated with s.
answer
str=s[1:5]
question
Write an expression whose value is the str consisting of all the characters (starting with the sixth) of the str associated with s.
answer
s[5:]
question
Assume that name is a variable of type String that has been assigned a value. Write an expression whose value is a String containing the first character of the value of name. So if the value of name were "Smith" the expression's value would be "S".
answer
name[0]
question
Given that s refers to a string, write an expression that evaluates to a string that is a substring of s and that consists of all the characters of s from its start through its ninth character.
answer
s[:9]
question
Write an expression that evaluates to True if the str associated with s starts with "p".
answer
s[0]=="p"
question
Write an expression whose value is True if all the letters in the str associated with s are upper case.
answer
s.isupper()
question
Write an expression that returns False if the str associated with s begins with "ecto".
answer
s[0:4]!='ecto'
question
Write an expression that returns True if the str associated with s ends with "ism".
answer
s[-3:]=='ism'