《python程序开发》试卷

更新时间: 试题数量: 购买人数: 提供作者:

有效期: 个月

章节介绍: 共有个章节

收藏
搜索
题库预览
将《共产党宣言》的英文序言,解析为一一个标准的单词列表。

text ="'A. spectre is haunting Europe the spectre of communism. All the powers of \ 

old Europe have entered into a holy alliance to exorcise this spectre: Pope \ 

and Tsar, Mettrnich and Guizot, French Radicals and German police-spies. \ 

Where is the party in opposition that has not been decried as communistic by \ 

its opponents in power? Where is the opposition that has not hurled back \ 

the branding reproach of communism, against the more advanced opposition \ 

parties, as well as against its reactionary adversaries?" 

print(clearVordsList) 

答: 

text ="'A. spectre is haunting Europe the spectre of communism. All the powers of \ 

old Europe have entered into a holy alliance to exorcise this spectre: Pope \ 

and Tsar, Mettrnich and Guizot, French Radicals and German police-spies. \ 

Where is the party in opposition that has not been decried as communistic by \ 

its opponents in power? Where is the opposition that has not hurled back \ 

the branding reproach of communism, against the more advanced opposition \ 

parties, as well as against its reactionary adversaries?" 

text = ___________________ # 将 text 字符串转换为小写字母 

wordsList =________________ # 以空格为分隔符切割字符串 

alphabetString = 'abcdefghijklmnopqrstuvwxyz' 

wordCount = _________________ # 计算单词列表的数量 

clearWordsList = [] 

for word in wordsList: 

 

if word[-1] not in alphabetString: 

 

______________________________________ # 单词最后一个字符不属于 26 个字母,将该单词 

添加到 clearWordsList 列表那个 

 

else: 

 

clearWordsList.append(word)

print(f'共产党宣言的序言部分共包含{wordCount}个单词:') 

___________________________________ # 输出最后的单词列表