题目内容

以下程序的功能是: s = "What’s a package, project, or release?We use a number of terms to describe software available on PyPI, like project, release, file, and package Sometimes those terms are confusing because they’re used to describe different things in other contexts Here’s how we use them on PyPI:A project on PyPI is the name of a collection of releases and files, and information about them Projects on PyPI are made and shared by other members of the Python community so that you can use themA release on PyPI is a specific version of a project For example, the requests project has many releases, like requests 210 and requests 121 A release consists of one or more filesA file, also known as a package, on PyPI is something that you can download and install Because of different hardware, operating systems, and file formats, a release may have several files (packages), like an archive containing source code or a binary wheel" s = s.lower() for ch in '’,?: ()': s = s.replace(ch," ") words = s.split() counts = {} for word in words: counts[word] = counts.get(word,0)+1 items = list(counts.items()) items.sort(key=lambda x:x[1],reverse = True) fo = open("wordnum.txt","w",encoding ="utf-8") for i in range(10): word,count = items[i] fo.writelines( word + ":" + str(count) + "\n") fo.close()

A. 统计字符串 s 中所有单词的出现次数,将单词和次数写入 wordnum.txt 文件
B. 统计字符串 s 中所有字母的出现次数,将单词和次数写入wordnum.txt 文件
C. 统计输出字符串 s 中前10个字母的出现次数,将单词和次数写入 wordnum.txt 文件
D. 统计字符串 s 中前10个高频单词的出现次数,将单词和次数写入 wordnum.txt 文件

查看答案
更多问题

下面代码的输出结果是 s =[“seashell”,“gold”,“pink”,“brown”,“purple”,“tomato”] print(s[4:])

A. [‘purple’]
B. [‘seashell’, ‘gold’, ‘pink’, ‘brown’]
C. [‘gold’, ‘pink’, ‘brown’, ‘purple’, ‘tomato’]
D. [‘purple’, ‘tomato’]

下面代码的执行结果是: d = {} for i in range(26): d[chr(i+ord(“a”))] = chr((i+13) % 26 + ord(“a”)) for c in “Python”: print(d.get(c, c), end="")

A. abugl
B. Python
C. Pabugl
D. Plguba

给出如下代码: while True: guess = eval(input()) if guess == 0x452//2: break 作为输入能够结束程序运行的是

A. 553
B. 0x452
C. “0x452//2”
D. break

下面代码的输出结果是 weekstr = “星期一星期二星期三星期四星期五星期六星期日” weekid = 3 print(weekstr[weekid: weekid+3])

A. 星期二
B. 星期三
C. 星期四
D. 星期一

答案查题题库