正确答案:
#any(x)判断x对象是否为空对象,如果都为空、0、false,则返回false,如果不都为空、0、false,则返回true
#all(x)如果all(x)参数x对象的所有元素不为0、''、False或者x为空对象,则返回True,否则返回False
14.
运行以下程序,
x = eval(input())
y = eval(input())
print(abs(x+y))
>>>def f(x, y =0, z =0):pass >>> f(1,,3)
正确答案:
19.
运行以下程序:
try:
num = eval(input("请输入一个列表:")) num.reverse()
print(num)
except:
print("输入的不是列表")
正确答案:
20.
以下程序的输出结果是:
def fun1(a,b,*args):
print(a)
print(b)
print(args)
fun1(1,2,3,4,5,6)
2
2
2
(3, 4, 5, 6)
正确答案:
21.
运行以下程序,当从键盘上输入{1:"清华大学",2:"大学"},运行结果的是:x =eval(input())
print(type(x))
from random import*
print(sample({1,2,3,4,5},2))
正确答案:
从前面那个取两个数出来
24.
以下程序的输出结果是:
import time
t = time.gmtime()
print(time.strftime("%Y-%m-%d %H:%M:%S",t))
ls =["浣熊","豪猪","艾草松鸡","棉尾兔","叉角羚"]
x ="豪猪"
print(ls.index(x,0))
lcat =["狮子","猎豹","虎猫","花豹","孟加拉虎","美洲豹","雪豹"] for s in lcat:
if"豹"in s:
print(s,end="")
continue
花豹
美洲豹
正确答案:
33.
以下程序的输出结果是:
s1 ="袋鼠"
print("{0}生活在主要由母{0}和小{0}组成的较小的群体里。
".format(s1))
袋鼠生活在主要由母袋鼠和小袋鼠组成的较小的群体里。
正确答案:
34.
以下程序的输出结果是:
s1 ="企鹅"
s2 ="超级游泳健将"
print("{0:^4}:{1:!<9}".format(s1,s2))
正确答案:
35.
以下程序的输出结果是:
for num in range(1,4):
sum *= num
print(sum)
正确答案:
Sum都没有赋值或者定义
36.
以下程序的输出结果是:
ls =["石山羊","一角鲸","南极雪海燕","竖琴海豹","山蝰"] ls.remove("山蝰")
str =""
print("极地动物有",end="") for s in ls:
str = str + s +"," print(str[:-1],end="。
")
正确答案:
37.
以下程序的输出结果是:
for i in"Summer":
if i =="m":
break
print(i)
正确答案:
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 them.A release on PyPI is a specific version of a project. For example, the requests project has many releases, like requests 2.10 and requests 1.2.1. A release consists of one or more files.A 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()
正确答案:。