import os #开始
def NewCaesar(m,n,t):
z='';i=0
while i<:
tmp=
if tmp in m:
if ord(t[i])<=90:
z+=n[m.find(tmp)]
else:
z+=n[m.find(tmp)].lower()
else:
z+=t[i]
i+=1
return z
m='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
n='QWERTYUIOPASDFGHJKLZXCVBNM'
a=input('请输入<明文>a=')
b=NewCaesar(m,n,a)
print('对应的密文为:',b)
c=NewCaesar(n,m,b)
print('解密后明文为:',c)
if :
print('加密解密成功!')
else:
print('加密解密失败!')
input("运行完毕,请按回车键退出...")
os._exit(0)
#结束

请回答下列问题:
import pandas as pd
df= pd. read _csv("data.csv")
df_ g=
df_ max=df_ _g["价格(元)"].max( )
df_ mean=
print(df_ max)
print(df_ mean)
请回答下列问题:
txt = open('chjfc. txt', 'r', encoding='utf-8'). read( )
words-txt. split( )
word_ counts={ }
for word in words:
if len(word)==1:
continue
else:
① #可以为1行或多行代码
#使用word_counts计算词语word在words中出现的次数
word_ list=list(word_counts. items( )) #返回所有键值对信息,生成列表
word_ list. sort(key-lambda x:x[1], reverse=True) #按词语出现次数降序排序
for i in range(20):
word, times= ②
print(word, times)
程序中划线①处应填写的代码是
程序中划线②处应填写的代码是

data. txt 记事本
他处理“data.txt”文件中英文单词的Python程序段如下:
file='data.txt'
word_ c=[]
n=0
for word in open(file):
if word[0:1]=='c':
word_c. append(word)
print(word)
print('字母c开头的单词个数:',n)
实现功能:绘制y=x2-2x+ 1的图像
#加载numpy模块并限简洁的别名为np
import numpy as np
#加载matplotlib.pyplot模块并限简洁的别名为plt
import matplotlib.pyplot as plt
#x在-7到9之间,每隔0.1取一个点
x=np.arange(-7,9,0.1)
= x**2-2*x+1
plt.plot(x,)
plt.title('y=x*x-2*x+1')
plt.xlabel('x')
plt.ylabel('y')
plt.
|
字段名 |
数据类型 |
备注 |
|
id |
int |
id字段数据为整型数值 |
|
name |
text |
name |
|
sage |
Datetime |
字段数据为字符型 |
|
sscx |
text |
sage字段数据为日期时间型 |
|
id |
name |
sage |
ssex |
|
1 |
张婷 |
2007- 1- 15 |
男 |
其命令代码为:
import sqlite3
conn = sqlite3.connec("test.db") #打开数据库
""添加记录函数""
def ins_ data(cu):
sql1 = "insert into data_ r (id, name, ssex) values ('16', '张婷', '女')"
cu.execute(sql)
conn.commit( )
"查询函数find(字段名,字段值)"
|
def find_ data(cu, xb):
print(cu.fetchall( )) #输出满足条件的所有记录 |
"主程序”
cur = conn.cursor( ) #创建游标
ins_ data(cur) #在游标处插入记录
xb="女"
find_ data(cur, xb) #调用函数查找字段ssex为变量xb的值
cur.close( )#关闭游标
conn.close( )
请在方框划线划线处完善查询记录find_data( )函数的代码,实现在test.db文件中data_ r数据表查询所有ssex字段值为xb的所有记录数据,并输出满足条件的所有记录。
import json #导入json库
file = open('tus. json', 'w', encoding='utf-8') #建立tusjson文件
b=[ ]
cur = conn.cursor( )
#将游标cur设置为id=1的记录,代码略
① #将游标处的记录存储到列表变量b中
Json.dump( ② , file) #dump是json函数,实现将数据保存到文件中
file.close( )
为实现上述功能,请在①处编写Python代码实现“将cur处的所有记录数据添加到列表变量b中”;划线②处应填入合适的代码为。
|
字段名 |
数据类型 |
备注 |
|
|
||
|
|
||
|
|

请完善横线处的代码,实现将resut数据表中字段key值为txt(网页表单输入的关键字字符)的记录保存到列表变量rec中,并统计数量保存到sum中。
from flask import Flask, render_template
import sqlite3
#打开Flask网页模板和打开数据库并建立conn对象等代码略
app= Flask(_ name_ )
app.config['SECRET_KEY']='xxx_Sss_ 1276589'
bootstrap = Bootstrap(app)
class NameForm(FlaskForm):
txt = StringField('查询:', validators=[DataRequired( )])
submit = SubmitField('搜索')
@app.route(/)
@app.route('/cx', methods=['GET', 'POST'])
def index_cx( ):
rec=[ ]
sum= 0
|
cu = conn.cursor( ) #建立游标对象
rec = #使用fetchall( )函数将结果保存到列表rec中 sum = #统计列表变量rec的数量 conn.commit( ) #执行数据库语句 ru.close#关闭游标对象 conn.close |
return render_ template('t4.html', form-myform, txt=sum)
if _name_ ='_main_':
app.run( )
import math
h = 500
g = 9.8
t = math.sqrt(2*h/g)
hx = g*(t-1)*(-1)/2
hh = h-hx
print(“小球最后1秒下落的位移是:”,hh,“m”)
请在划线处填入合适的代码。
s=input("请输入波群(m)")
a=[]
s=s+","
for j in range(len(s)):
if s[j] == ",":
t = float(s[i:j])
a.append(t) #append方法用于在列表末尾添加新元素
a.sort(reverse = True) #将a列表中的元素从大到小排列
sumbg=0
for k in range(len(a)//3):
sumbg = sumbg + a[k]
print("有效波高(m):",aver)
from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
from random import random
s=input("依次输入左上角和右下角的坐标值(以‘,’分隔,以‘,’结尾):")
w=[];h=[];k=0;t=0
for i in s:
if i==",":
if k%2==0:
w.append(t) #append方法用于在列表末尾添加新元素
else:
h.append(t)
t=0;k=k+1
else:
print(w,h)
im = #打开图像y.jpg
pix=im.load()
for i in range():
j= h[0]
while j<=h[1]:
R,G,B=pix[i,j]
pix[i,j]=(int(random()*0.8*R),int(random()*0.8*G),int(random()*0.8*B))
j+=1
plt.figure("y1") #指定当前绘图对象
plt.imshow(im) #显示图像
plt.axis("off") #关闭图像坐标
plt.show() #弹出包含了图片的窗口
图a
使用Python读取表格中的数据,代码如下,根据题意填写划线部分:
import pandas as pd
df=pd.read_excel("销售.xlsx")
print() #筛选出商品原价大于等于1000的记录。
df1=df.groupby("客服",as_index=False)["订单金额"].sum()
df1.rename(columns={"订单金额":"订单总额"},inplace=True)
df2=
print( df2 ) #按“订单总额”降序排序后输出前10条记录
#以下代码功能为:绘制“各月份销售额”的折线图,结果如图b所示。
图 b
import matplotlib.pyplot as plt
df3=df.groupby("月份",as_index=False)["订单金额"].sum()
plt.figure(figsize=(10,5))
plt.title('各月份销售额')
plt. (df3["月份"],df3["订单金额"])
plt.xlabel('各月份')
plt.ylabel("订单金额")
plt.show( )
图a
import pandas as pd
import matplotlib.pyplot as plt
df=pd.read_excel("ymjz.xlsx")
#输出功能:输出接种台数大于2的接种单位名称
df1=df[ ]
print(df1.单位)
#统计功能:统计各区县的医务人员数量
g=df.groupby("区县",as_index=False)["医务人员数"]
df2=
print(df2)
#分析功能:分析本市各类别(常规、方舱、医疗临时点、校企临时点、其他)接种单位的数量情况并制作图表呈现
g=df.groupby("类别",as_index=False)
df3=g.count()
df3=
plt.
(df3.类别,df3.单位)
plt.show()
图b

import pandas as pd
df=pd. read_excel ('微课点击量.x1sx')
df1=df. group by("科目", as_index=False). sum()
df2=