MyProgrammingLab Starting out with python ch.8

¡Supera tus tareas y exámenes ahora con Quizwiz!

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".

'http://'+address

Write an expression that concatenates the String variable suffix onto the end of the String variable prefix .

prefix+suffix

Write an expression whose value is True if all the letters in the str associated with s are upper case.

s.isupper()

Write an expression that evaluates to True if the str associated with s starts with "p".

s[0]=="p"

Write an expression whose value is the character at index 3 of the str associated with s.

s[3]

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)"

"(" + word + ")"

Write an expression that is the concatenation of the strings "Hello" and "World".

'Hello'+'World'

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".

name1+','+name2+','+name3

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".

name[0]

Write an expression that is the concatenation of the str associated with s1 and that associated with the str s2.

s1+s2

Write an expression whose value is the last character in the str associated with s.

s[-1]

Write an expression whose value is the str that consists of the second to last character of the str associated with s.

s[-2]

Write an expression that returns True if the str associated with s ends with "ism".

s[-3:]=='ism'

Write an expression whose value is the str that consists of the third to last character of the str associated with s

s[-3]

Write an expression that returns False if the str associated with s begins with "ecto".

s[0:4]!='ecto'

Write an expression whose value is the str consisting of all the characters (starting with the sixth) of the str associated with s.

s[5:]

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.

s[:9]

Write an expression whose value is the str that consists of the second through fifth characters of the str associated with s.

str=s[1:5]

Write an expression whose value is the str that consists of the first four characters of the str associated with s.

str=s[:4]


Conjuntos de estudio relacionados

Test 2 PrepU (Ch 4,8-11, 26-28, 32-34), Resp., renal, reprod., A/B

View Set

Chapter 28: The Child with Endocrine Dysfunction

View Set

International Business Chapter 8

View Set

statistical analysis of differences

View Set

Unit 3 Personal Fitness Topic Test

View Set

Membranes in the Ventral Body Cavity

View Set

8.1.3 Inflammatory Bowel Disease

View Set

CFA Level 1 Ethical and Professional Standards

View Set