以下语句的内容是什么?
name = 'Reginald Peoplesmythe'
print(name[-2] + name[-3])
Group of answer choices
A。例如
B。 ty
C。 ht
以下语句的内容是什么?
name = 'Barnacle Bill the Sailor'
print(name[-len(name)])
Group of answer choices
A。 r
B。 B
C。没有-这是无效的索引
以下语句的内容是什么?
name = 'Barnacle Bill the Sailor'
print(name[1])
Group of answer choices
B
a
水手藤壶比尔
以下语句的内容是什么?
name = 'Barnacle Bill the Sailor'
print(name[2:4])
Group of answer choices
rnac
rn
rna
以下语句的内容是什么?
name = 'Worthingham'
print(name[8:])
Group of answer choices
ham
gham
没有-这是无效的切片
将这个问题标记问题61分以下语句显示了什么?
name = 'Worthingham'
print(name[10:])
Group of answer choices
am
m
没有-这是无效的切片
变量r在此代码末尾具有什么值?
s = "four"
r = "six"
for item in s:
r = r + item.upper()
Group of answer choices
sixFOUR
RUOFsix
RUOFxis
这是Python list
主题,重点是negative index
-ing。
在Python列表(以及元组)中,您可以使用负索引获取(和切片)列表中的元素。
示例:
>> name = 'Reginald Peoplesmythe'
>> print(name[-2] + name[-3])
-1
的元素(即最后一个元素是e
。
这意味着索引为-2
的元素为h
,索引为-3
的元素为t
。
因此,print(name[-2] + name[-3])
将显示ht
。
您应该能够找出其余的问题。