Deck 9: More About Strings
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/35
العب
ملء الشاشة (f)
Deck 9: More About Strings
1
What will be assigned to s_string after the execution of the following code? special = '1357 Country Ln.'
S_string = special[-3: ]
A) '531'
B) 'Ln.'
C) ' Ln.'
D) '7531'
S_string = special[-3: ]
A) '531'
B) 'Ln.'
C) ' Ln.'
D) '7531'
B
2
The index - 1 identifies the last character in a string.
True
3
What will be assigned to s_string after the execution of the following code? special = '1357 Country Ln.'
S_string = special[ :4]
A) '7'
B) '1357'
C) '1357 '
D) Invalid code
S_string = special[ :4]
A) '7'
B) '1357'
C) '1357 '
D) Invalid code
B
4
Which of the following string methods can be used to determine if a string contains only '\n' characters?
A) ischar()
B) isalpha()
C) istab()
D) isspace()
A) ischar()
B) isalpha()
C) istab()
D) isspace()
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
5
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
6
Invalid indexes do not cause slicing expressions to raise an exception.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
7
In slicing, if the end index specifies a position beyond the end of the string, Python will use the length of the string instead.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
8
What will be assigned to the string variable pattern after the execution of the following code? i = 3
Pattern = 'z' * (5*i)
A) 'zzzzzzzzzzzzzzz'
B) 'zzzzz'
C) Error: '*' operator used incorrectly
D) The right side of the '*' must be an integer.
Pattern = 'z' * (5*i)
A) 'zzzzzzzzzzzzzzz'
B) 'zzzzz'
C) Error: '*' operator used incorrectly
D) The right side of the '*' must be an integer.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
9
What is the value of the variable string after the execution of the following code? string = 'abcd'
String.upper()
A) 'abcd'
B) 'Abcd'
C) 'ABCD'
D) Invalid code
String.upper()
A) 'abcd'
B) 'Abcd'
C) 'ABCD'
D) Invalid code
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
10
Which method would you use to determine whether a substring is the suffix of a string?
A) endswith(substring)
B) find(substring)
C) replace(string, substring)
D) startswith(substring)
A) endswith(substring)
B) find(substring)
C) replace(string, substring)
D) startswith(substring)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
11
If the start index is _____ the end index, the slicing expression will return an empty string.
A) equal to
B) less than
C) greater than
D) not equal to
A) equal to
B) less than
C) greater than
D) not equal to
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
12
What will be assigned to s_string after the execution of the following code? special = '1357 Country Ln.'
S_string = special[4: ]
A) '1357'
B) 'Country Ln.'
C) ' Country Ln.'
D) Invalid code
S_string = special[4: ]
A) '1357'
B) 'Country Ln.'
C) ' Country Ln.'
D) Invalid code
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
13
What is the return value of the string method lstrip()?
A) The string with all whitespace removed
B) The string with all leading spaces removed
C) The string with all leading tabs removed
D) The string with all leading whitespaces removed
A) The string with all whitespace removed
B) The string with all leading spaces removed
C) The string with all leading tabs removed
D) The string with all leading whitespaces removed
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
14
Which list will be referenced by the variable list_strip after the execution of the following code? list_string = '03/07/2008'
List_strip = list_string.split('/')
A) ['3', '7', '2008']
B) ['03', '07', '2008']
C) ['3', '/', '7', '/', '2008']
D) ['03', '/', '07', '/', '2008']
List_strip = list_string.split('/')
A) ['3', '7', '2008']
B) ['03', '07', '2008']
C) ['3', '/', '7', '/', '2008']
D) ['03', '/', '07', '/', '2008']
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
15
What is the first negative index in a string?
A) 0
B) -1
C) -0
D) Size of the string minus one
A) 0
B) -1
C) -0
D) Size of the string minus one
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
16
Indexing works with both strings and lists.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
17
What will be assigned to the string variable even after the execution of the following code? special = '0123456789'
Even = special[0:10:2]
A) '13579'
B) '2468'
C) '02468'
D) Invalid code
Even = special[0:10:2]
A) '13579'
B) '2468'
C) '02468'
D) Invalid code
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
18
What is the value of the variable string after the execution of the following code? string = 'Hello'
String += ' world'
A) 'Hello'
B) ' world'
C) 'Hello world'
D) Invalid code
String += ' world'
A) 'Hello'
B) ' world'
C) 'Hello world'
D) Invalid code
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
19
Which method would you use to determine whether a substring is present in a string?
A) endswith(substring)
B) find(substring)
C) replace(string, substring)
D) startswith(substring)
A) endswith(substring)
B) find(substring)
C) replace(string, substring)
D) startswith(substring)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
20
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
A) 0 through 7
B) 0 through 8
C) -1 through -8
D) -1 through 6
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
21
The _______________ operator can be used to determine whether one string is contained in another string.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
22
The _______________ method returns a copy of the string with all alphabetic letters converted to lower case.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
23
When accessing each character in a string, such as for copying purposes, you would typically use a while loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
24
The _______________ method returnst if the string contains only numeric digits.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
25
A(n) _______________ is a span of characters that are taken from within a string.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
26
A(n) _______________ exception will occur if you try to use an index that is out of range for a particular string.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
27
The _______________ method returns the list of the words in the string.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
28
The strip() method returns a copy of the string with all leading whitespace characters removed, but does not remove trailing whitespace characters.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
29
An expression of the form string[i] = 'i' is a valid expression.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
30
When the operand on the left side of the * symbol is a string and the operand on the right side is an integer, it becomes the _______________ operator.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
31
The third number in string slicing brackets represents the _______________ value.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
32
Strings are _______________, which means that once a string is created, it cannot be changed.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
33
Each character in a string has a(n) _______________ which specifies its position in the string.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
34
If the + operator is used on strings, it produces a string that is the combination of the two strings used as its operands.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
35
If a whole paragraph is included in a single string, the split() method can be used to obtain a list of the sentences included in the paragraph.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck