while True:
for event in pygame.event.get(): #()
if event.type==pygame.QUIT: #( )
sys.exit() #退出程序
if event.type==pygame.MOUSEBUTTONDOWN: #( )
screen.fill((255,255,0)) #窗口填充黄色*
#加载背景图像
#将背景图画在窗口
pygame.display.update() #窗口刷新
import pandas as pd
s1 = pd.Series(range(1,10,2))
print(s1)
该程序段运行后输出结果为( )
import pandas as pd
df1=pd. DataFrame([[10, 20], [30, 40]], columns=['A','B'])
df2=pd. DataFrame([50, 60], [70, 80]], columns=['A',B'])
df=df1. append(df2,ignore_ index= True)
print(df)
该程序段运行后输出结果为( )
B .
D .

代码中“import music”表示导人music模块,它包含了生成和控制声音的方法,music.pitch(freq,8)表示播放设定频率的曲调,时间为8ns。下载并运行该代码,在蜂鸣器中听到的声音效果是( )
#数据库中获取数据存储在列表中
import json #导入json函数库
① #导入SQLite函数库
conn = sqlite3.connect("test.db")
json_ info=[] #变量json_info存储记录数据
cur = conn.cursor( )
sql= "select * fromstd ② " #查询ssex字段值为“man”的所有记录
cur.execute(sql)
json_ info = cur.fetchal( ) #将符合记录数据保存到变量json_info
conn.commit( )
cur.close( )
conn.close( )
#将记录转换为json格式的数据
file = open('b.json', 'w', encoding-'utf-8') #打开json格式文件
json.dump( ③ , file) #将变量json_info转换为json格式保存到文件中
file.close( )
请回答下列问题:
① ② ③
s=input("请输入一个姓名并回车")*50
B . s=[]for x in range(50):
s=s+[input('请输入一个姓名并回车')]
C . s=""for x in range(50):
s+=input("请输入一个姓名并回车")
D . for x in range(50):s=[]
s=s+[input('请输入一个姓名并回车')]
| ①import random print(random.choice(s)) | ②import random n=random.randint(0,49) print(s[n]) |
| ③import random for n in range(50): print(s[n]) | ④import random n=int(input("请输入0-49间任意整数:")) print(s[n]) |
程序描述:2公里(包括2公里)内,起步价为5元,超过2公里部分(不足整公里的,向上取整),每公里1.6元。
代码如下:
Import ① #引用math库
s= ② (input("请输入你要去目的地距离出发点的公里数:))
If ③ : #2公里(包括2公里)内
cost =5
else:
cost = 5+math.ceil(s-2) *1.6
print("你的打的费用是", cost,“元)
①处的语句是,②处的语句是,③处的语句是
①A.math B.Numpy C.time D.Matplotlib
②A.Float B.Int C.str D.Math
③A.s≤2 B.s<=2 C.s>2 D.s≥2
|
图1 |
图2 |
为分析数据,小张编写了如下程序:
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.pyplot import MultipleLocator
plt.rcParams['font.sans-serif']=['SimHei'] #正常显示中文标签
df=pd.read_csv("dongao.csv")
#删除所有未获得奖牌的记录,并将奖牌列中的"G"修改为"金牌","S"修改为"银牌","B"修改为"铜牌"
jp={'G':'金牌','S':'银牌','B':'铜牌'}
for i in df.index:
if ① :
df=df.drop(i)
else:
df.at[i,'奖牌']=jp[df.at[i,'奖牌']]
#对输入国家每届的奖牌数进行统计,并制作相应图表,如第14题图2所示:
nt=input("请输入国家名称:")
df1=df[df['国家']==nt]
df3=pd.DataFrame(df2) #将分组后数据生成新的二维结构,索引为“届次”,列标题为“奖牌”
x=df3.index
y= ②
plt.title(nt+"历年冬奥会奖牌趋势图")
plt. ③ (x,y)
plt.show()
df2=df1.届次.count()
B . df2=df1.groupby('届次')df2=df2['奖牌'].count()
C . df2=df1.groupby('奖牌')['届次’].count() D . df2=df1.groupby('届次').奖牌.count()from random import randint
a=[0]*6
for i in range(6):
a[i]=randint(1, 10)
for i in range(6):
if a[i]%2==0 and i%2== 0:
a[i] += 1
elif i%2==1:
a[i]=a[i]+a[i- 1]
print(a)
程序运行后,输出结果可能是 ( )
