下列说法正确的是( )
x,y,z=142,125,120
res=0
if x>y:
res=x
elif y>z:
res+=z
res-=5
print(res)
运行该程序段后,输出结果是( )
a=[]
b=[1,5,4,1,5]
c={1:3,2:4,3:5,4:1,5:2}
for i in b:
if i not in a:
a.append(c[i])
print(a)
运行该程序段后,列表a的值是( )
n=int(input("please input n:"))
s=0
for i in range(1,n):
if i % 3==0:
s=s+i
print("s=",s)
程序执行时,输入n的值为25,则输出的结果为( )
n=int(input("输入斐波那契数列长度:"))
a=[0]*n #生成列表a为[0,0,0,…],列表中为n个0
a[0]=a[1]=1
i=2 #①
while i < n: #②
a[i]=a[i-2]+a[i-1] #③
i+=1
print(a[i]) #④
该程序运行后显示出错信息,则出错的语句是( )
s="6p25y3t";sum=t=0;flag=True
for ch in s:
if "0"<=ch<="9":
t=t*10+int(ch)
else:
if flag==True:
sum+=t
t=0
flag=not flag
执行该程序段后,变量 sum 的值为( )
sw="日一二三四五六"
y=int(input("请输入年份:"))
m=int(input("请输入月份:"))
d=int(input("请输入日期:"))
print(y,"年",m,"月",d,"日")
if :
m=m+12
week=(d+2*m+3*(m+1)//5+y+y//4-y//100+y//400+1)%7
weekday=
print("星期"+weekday)
dic={"2":1,"6":2,"8":3,"4":-2}
cp=input("请输入车牌号(格式如'浙H94286'):")
count=0
for i in :
x=cp[i]
if x in ["2","4","6","8"]:
print("该车牌号的吉利值为:" + )
dx={"0":"零","1":"壹","2":"贰","3":"叁","4":"肆","5":"伍","6":"陆","7":"柒","8":"捌","9":"玖"}
dw="亿仟佰拾萬仟佰拾元"
money=input("请输入金额(整数,不得超过9位):")
zh=""
t=""
if ① :
print("输入的数据超出所能转换的范围。")
else:
for i in range(0, len(money)):
t= ② #取出第i位小写对应的大写
dwz=len(dw)-len(money)+i #计算该小写数字对应的单位在dw中的索引号
③
print(money+"的大写为:"+zh+"整")
① ② ③
该程序运行的部分界面如下图所示,请在程序划线处填入合适的代码。
ore = int(input("请输入矿石质量:"))
weights = [50,20,10,5,2,1] #砝码规格
#初始化所需的各规格砝码数量
num = [0]*len(weights) #生成列表num为[0,0,0,…],列表中为len(weights)个0
res = "所需的砝码:"
while ore > 0:
num[i] = ore // weights[i]
i += 1
for i in range(len(num)):
if :
res = res + str(weights[i]) + "g:" + str(num[i]) + "个;"
print(res[:-1])