字符串 s = “I love Python”,以下程序的输出结果是: s = “I love Python” ls = ssplit() lsreverse() print(ls)
A. ‘Python’, ‘love’, ‘I’
B. Python love I
C. None
D. [‘Python’, ‘love’, ‘I’]
执行以下程序,输入”93python22”,输出结果是: w = input(‘请输入数字和字母构成的字符串:’) for x in w: if ‘0’<= x <= ‘9’: continue else: w.replace(x,’’) print(w)
A. python9322
B. python
C. 93python22
D. 9322
以下程序的功能是: 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’]