a=int(input("请输入一个数:"))
if a>0:
a=a%10
elif a==0:
a=a+1
else:
a=a**2
a=a+10
print(a)
输入a值为20,执行该程序段后,输出的结果是( )
ma=a[0];mb=a[0];pa=0;pb=0
for i in range(1,10):
if ma < a[i]:ma = a[i];pa=i
if mb > a[i]:mb = a[i];pb=i
下列关于该程序段功能描述正确的是( )
①next[p]= next[r] ②next[p]= r ③next[r]= p
④next[r]= -1 ⑤next[r]= next[p] ⑥next[p]= -1
a = [3,2,1,-8,3,-2,8,6]
s = t = a[0]
for i in range(1,len(a)):
if s > 0:
s += a[i]
else:
s = a[i]
if s > t:
t = s
print(t)
该程序段的运行结果是( )
import pandas as pd
s1=pd.Series(["赵天一","周光起","王子涵","徐静怡"],index=["01","02","03","04"])
s1["02"]="周广其"
xh=s1.index
name=s1.values
height=[168,175,170,180]
weight=[57,65,62,65]
col=["姓名","身高","体重"]
data={"姓名":name,"身高":height,"体重":weight}
df1=pd.DataFrame(data,index=xh,columns=col)
print(df1[df1["身高"]>170])
运行该程序段,输出显示的内容为( )
from random import randint
a=[0]*6; i=0
while i<6:
a[i]=randint(1,10)
if a[i]%2==i%2:
i=i-1
elif i%2==1:
a[i]=a[i-1]+a[i]
i=i+1
执行该程序段后,数组 a 中的值可能为( )
import pandas as pd
import matplotlib.pyplot as plt
df=pd.read_excel("成绩表.xlsx")
df=df.rename(columns={"选择题总分":"选择题"})
print(df1)
请在划线处填写合适的代码。
num=int(input("请输入小组:"))
plt.figure(figsize=(10,5))
list=[]
for i in range(12):
s="题"+str(i+1)
list.append(*50)
plt.bar(range(1,13),list)
plt.title(str(num)+"group")
plt.xlabel("question number")
plt.ylabel("correct rate")
plt.show()
n=int(input("n="))
m=int(input("m="))
lst=[]
for i in range(n-1):
lst.append([i+1,i+1])
lst.append( ) #将尾节点的指针指向头节点,构成循环单向链表
p=len(lst)-1
while n>1:
for i in range(1,m): #从1~(m-1)依次报数
out=lst[p][1]
n=n-1
print("最后留下的同学的编号是:", lst[p][0])
n=int(input("n="))
m=int(input("m="))
q=[0]*n ; head=0 ; tail=0
for i in range(1,n+1): #构造循环队列
q[tail]=i
c=0
while (head+1)%n!=tail:
c=c+1
if c==m:
head=(head+1)%n
else:
tail=(tail+1)%n
head=(head+1)%n
print("最后留下的同学的编号是: ",q[head])
一个选项是否被填涂,可以从判断一个像素的颜色开始,像素的填涂情况是通过RGB的值来判断 ,灰度值低于132的表示该点被填涂;一个信息点64%的像素被填涂,则认为该区域已填涂,返回值为“1”。区域未填涂时返回值为“0”;各选项的编码为:A→“1000”,B→“0100”,C→“0010”,D→“0001”;输入标准答案,程序进行对比并返回结果。答题卡相关信息如下:
from PIL import Image
#输入起始点坐标(xs,ys),信息点宽度高度(fw, fh),间隔宽度高度(sw, sh),代码略
num = 5 # 判分个数
def bw_judge(R, G, B): # bw_judge用于判断一个像素的填涂情况,代码略
def fill_judge(x, y): # fill_judge用于判断信息点的填涂情况
count = 0
for i in range(x, x + fw + 1):
for j in range(y, y + fh + 1):
R, G, B = pixels[i, j]
if bw_judge(R, G, B) = = True:
count = count + 1
return
total_width = fw+ sw
total_height = fh + sh
image = Image.open("t2.bmp")
pixels = image.load()
number = ""
bz=[""]*num
df=0
bzd=input('请输入标准答案:')
da={"A":"1000","B":"0100","C":"0010","D":"0001"}
for i in range(len(bzd)):
bz[i]=
for row in range(num): #分数判定
for col in range(4):
y = ys + total_height * row
if fill_judge(x, y) == True :
number = number + '1'
else:
number = number + '0'
if number = = bz[row]:
df+=2
number=""
print("得分为:",df)