Filters
Question type

Study Flashcards

What will be assigned to the string variable pattern after the following code executes? I = 3 Pattern = 'z' * (5 * i)


A) 'zzzzzzzzzzzzzzz'
B) 'zzzzz'
C) 'z * 15'
D) Nothing; this code is invalid

Correct Answer

verifed

verified

What is the first negative index in a string?


A) 0
B) -1
C) -0
D) the size of the string minus one

Correct Answer

verifed

verified

The __________ method returns the list of the words in a string.

Correct Answer

verifed

verified

Indexing works with both strings and lists.

Correct Answer

verifed

verified

What will be displayed after the following code executes? Mystr = 'yes' Yourstr = 'no' Mystr += yourstr * 2 Print(mystr)


A) yes + no * 2
B) yes + no yes + no
C) yesnono
D) yesnoyesno

Correct Answer

verifed

verified

What will display after the following code executes? Password = 'ILOVEPYTHON' If password.isalpha() : Print('Invalid,must contain one number.') Elif password.isdigit() : Print('Invalid,must have one non-numeric character.') Elif password.isupper() : Print('Invalid,cannot be all uppercase characters.') Else: Print('Your password is secure!')


A) Invalid, must contain one number.
B) Invalid, must have one non-numeric character.
C) Invalid, must contain one number.
Invalid, cannot be all uppercase characters.
D) Your password is secure!

Correct Answer

verifed

verified

The strip()method returns a copy of the string with all the leading whitespace characters removed but does not remove trailing whitespace characters.

Correct Answer

verifed

verified

False

What will be the value of the variable string after the following code executes? String = 'Hello' String += ' world!'


A) 'Hello'
B) ' world!'
C) 'Hello world!'
D) Nothing; this code is invalid

Correct Answer

verifed

verified

The __________ method returns True if the string contains only numeric digits.

Correct Answer

verifed

verified

Each character in a string has a(n)__________ which specifies its position in the string.

Correct Answer

verifed

verified

The isalpha()method returns __________ if the string contains only alphabetic characters and is at least one character in length.

Correct Answer

verifed

verified

What will be assigned to the variable s_string after the following code executes? Special = '1357 Country Ln.' S_string = special[-3:]


A) '135'
B) '753'
C) 'Ln.'
D) 'y Ln'

Correct Answer

verifed

verified

Indexing of a string starts at 1 so the index of the first character is 1,the index of the second character is 2,and so forth.

Correct Answer

verifed

verified

False

When accessing each character in a string,such as for copying purposes,you would typically use a while loop.

Correct Answer

verifed

verified

What are the valid indexes for the string 'New York'?


A) 0 through 7
B) 0 through 8
C) -1 through -8
D) -1 through 6

Correct Answer

verifed

verified

A(n)__________ exception will occur if you try to use an index that is out of range for a particular string.

Correct Answer

verifed

verified

What will be the value of the variable string after the following code executes? String = 'abcd' String.upper()


A) 'abcd'
B) 'ABCD'
C) 'Abcd'
D) Nothing; this code is invalid

Correct Answer

verifed

verified

What will be assigned to the variable s_string after the following code executes? Special = '1357 Country Ln.' S_string = special[ :4]


A) '7'
B) '1357'
C) 5
D) '7 Country Ln.'

Correct Answer

verifed

verified

The third number in string slicing brackets represents the ___________ value.

Correct Answer

verifed

verified

The __________ method returns a copy of the string with all the alphabetic letters converted to lower case.

Correct Answer

verifed

verified

lower()

Showing 1 - 20 of 37

Related Exams

Show Answer