当前位置:   article > 正文

【python】字符串基础练习题(3)答案_python用字符串的连接操作, 输出: ‘这是我的字符串基础练习答案’

python用字符串的连接操作, 输出: ‘这是我的字符串基础练习答案’

Python string练习3 答案

第1题

请输出News中每个字符出现的次数。

# 第1题
T:2次
h:18次
e:47次
 :81次
U:5次
N:3次
S:4次
c:18次
u:14次
r:19次
i:28次
t:32次
y:8次
C:4次
o:29次
n:29次
l:16(1)1次
d:17次
a:28次
p:6次
R:3次
s:30226131次
f:4次
":6次
m:6次
g:3次
G:2次
A:3次
b:6次
k:1.4次
I:2,3次
v:41351次
w:4次
E:1
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
第2题

将News中的每个单词分隔出来(包括标点符号,以空格为界)到News_split中并输出。

['The', 'UN', 'Security', 'Council', '(UNSC)', 'on', 'Sunday', 'adopted', 'Resolution', '2623', 'that', 'calls', 'for', 'an', '"emergency', 'special', 'session"', 'of', 'the', 'UN', 'General', 'Assembly', 'on', 'the', 'Ukraine', 'crisis.', 'It', 'is', 'the', 'first', 'such', 'a', 'resolution', 'that', 'the', 'council', 'has', 'adopted', 'in', 'four', 'decades,', 'according', 'to', 'the', 'Security', 'Council', 'Report.', 'The', 'vote', 'by', 'the', '15', 'member', 'council', 'was', 'procedural,', 'and', 'the', 'resolution', 'convening', 'the', 'General', 'Assembly', 'session', 'was', 'adopted', 'with', '11', '"yes"', 'votes.', 'Russia', 'voted', '"no"', 'while', 'the', 'United', 'Arab', 'Emirates,', 'India', 'and', 'China', 'abstained.']
  • 1
第3题

记录News所有的标点符号到列表punc中。

['(', ')', '"', '"', '.', ',', '.', ',', '"', '"', '.', '"', '"', ',', '.']
  • 1
第4题

根据punc,将News_split中所有元素两头的标点符号去掉,并输出。

['The', 'UN', 'Security', 'Council', 'UNSC', 'on', 'Sunday', 'adopted', 'Resolution', '2623', 'that', 'calls', 'for', 'an', 'emergency', 'special', 'session', 'of', 'the', 'UN', 'General', 'Assembly', 'on', 'the', 'Ukraine', 'crisis', 'It', 'is', 'the', 'first', 'such', 'a', 'resolution', 'that', 'the', 'council', 'has', 'adopted', 'in', 'four', 'decades', 'according', 'to', 'the', 'Security', 'Council', 'Report', 'The', 'vote', 'by', 'the', '15', 'member', 'council', 'was', 'procedural', 'and', 'the', 'resolution', 'convening', 'the', 'General', 'Assembly', 'session', 'was', 'adopted', 'with', '11', 'yes', 'votes', 'Russia', 'voted', 'no', 'while', 'the', 'United', 'Arab', 'Emirates', 'India', 'and', 'China', 'abstained']
  • 1
第5题

根据以下规则把News_split中所有元素中所有数字替换为大写英文字母:“1234567890”<=>“ABCDEFGHIJ”,并输出。

['The', 'UN', 'Security', 'Council', 'UNSC', 'on', 'Sunday', 'adopted', 'Resolution', 'BFBC', 'that', 'calls', 'for', 'an', 'emergency', 'special', 'session', 'of', 'the', 'UN', 'General', 'Assembly', 'on', 'the', 'Ukraine', 'crisis', 'It', 'is', 'the', 'first', 'such', 'a', 'resolution', 'that', 'the', 'council', 'has', 'adopted', 'in', 'four', 'decades', 'according', 'to', 'the', 'Security', 'Council', 'Report', 'The', 'vote', 'by', 'the', 'AE', 'member', 'council', 'was', 'procedural', 'and', 'the', 'resolution', 'convening', 'the', 'General', 'Assembly', 'session', 'was', 'adopted', 'with', 'AA', 'yes', 'votes', 'Russia', 'voted', 'no', 'while', 'the', 'United', 'Arab', 'Emirates', 'India', 'and', 'China', 'abstained']

# '2623'转成'BFBC', '15'转成'AE', '11'转成'AA'
  • 1
  • 2
  • 3
第6题

大写转小写,小写转大写。

['tHE', 'un', 'sECURITY', 'cOUNCIL', 'unsc', 'ON', 'sUNDAY', 'ADOPTED', 'rESOLUTION', 'bfbc', 'THAT', 'CALLS', 'FOR', 'AN', 'EMERGENCY', 'SPECIAL', 'SESSION', 'OF', 'THE', 'un', 'gENERAL', 'aSSEMBLY', 'ON', 'THE', 'uKRAINE', 'CRISIS', 'iT', 'IS', 'THE', 'FIRST', 'SUCH', 'A', 'RESOLUTION', 'THAT', 'THE', 'COUNCIL', 'HAS', 'ADOPTED', 'IN', 'FOUR', 'DECADES', 'ACCORDING', 'TO', 'THE', 'sECURITY', 'cOUNCIL', 'rEPORT', 'tHE', 'VOTE', 'BY', 'THE', 'ae', 'MEMBER', 'COUNCIL', 'WAS', 'PROCEDURAL', 'AND', 'THE', 'RESOLUTION', 'CONVENING', 'THE', 'gENERAL', 'aSSEMBLY', 'SESSION', 'WAS', 'ADOPTED', 'WITH', 'aa', 'YES', 'VOTES', 'rUSSIA', 'VOTED', 'NO', 'WHILE', 'THE', 'uNITED', 'aRAB', 'eMIRATES', 'iNDIA', 'AND', 'cHINA', 'ABSTAINED']
  • 1
第7题

筛选出所有小写字母

tunscunscsrbfbcungauiscrtaegaaaruaeic
  • 1
第8题

分割,填充,补齐

['qqqqqqqqqqqt', 'qqqqqqqqqnsc', 'qqqnscsrbfbc', 'qqqqqqqqqnga', 'iscrtaegaaar', 'qqqqqqqqaeic']
  • 1
第9题

换表

['g', 'wla', 'wlalbiba', 'wr', 'flager', 'efa']
  • 1
第10题

筛选,换表,得到flag。

Flag{noon}fterlal_Easy_afternoon}
  • 1
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/712936
推荐阅读
相关标签
  

闽ICP备14008679号