【python】字符串基础练习题(3)答案

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
第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.']
第3题

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

['(', ')', '"', '"', '.', ',', '.', ',', '"', '"', '.', '"', '"', ',', '.']
第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']
第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'
第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']
第7题

筛选出所有小写字母

tunscunscsrbfbcungauiscrtaegaaaruaeic
第8题

分割,填充,补齐

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

换表

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

筛选,换表,得到flag。

Flag{noon}fterlal_Easy_afternoon}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

CHOITAKWAI

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值