第19届杭州亚运会组委会推出了国际大型综合性运动会史上首个一站式数字观赛服务APP——智能亚运一站通,包含“知识通”、“美食通”、“出行通”等模块,运用区块链、大数据、人工智能等高新技术,对接浙江数字城市各类资源,整合亚运城市各类场景应用。用户下载该APP后,可以从“食、住、行、游、购、娱”六个方面获取服务,非常方便快捷。
def encode(msg,key) :
result=""
for i in range(0,len(msg)) :
c=msg[i]
if "a"<=c<="z":
result=chr((ord(c)+key-ord("a"))%26+ord("a"))+result
elif "0"<=c<="9" :
result=result+chr((ord(c)-key-ord("0"))%10+ord("0"))
return result
msg=input("请输入明文:")
key=int(input("请输入密钥:"))
re=encode(msg,key)
print(re)
程序运行后,输入 msg 的值为“1a2b3c” ,key=2,输出的结果是( )
智能终端程序代码如下所示:
from microbit import *
import Obloq
IP = "192. 168.0. 123" PORT = "8080"
SSID = "xiaoming123"
# Web 服务器的地址
# Web 服务器的端口
# Wi-Fi 的 SSID
PASSWORD = "yanwu888" # Wi-Fi 的密码
uart.init(baudrate=9600,bits=8,parity=None,stop= 1,tx=pin2,rx=pin1)
while Obloq.connectWifi(SSID,PASSWORD, 10000) != True:
display.show(".")
display.scroll(Obloq.ifconfig())
Obloq.httpSet(IP,PORT)
while True:
temp = pin0.read_analog()
errno,resp = Obloq.get("input?id=1&val="+str(temp), 10000)
if temp>=180:
pin1.write_digital(1)
else:
pin1.write_digital(0)
sleep( 10000)
图 a
图b
import pandas as pd
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
df = pd.read_excel("qndxx.xlsx") | |
dfl = df.① | #按班级列进行分组 |
df2=df1.学校.count( ) | #统计各班级学习人数 |
df2=df2.rename(columns= {"学校":"人数"}) | |
df3=df2.sort_values ("人数",ascending=True).head(10) print(df3) | #筛选前 10 名 |
② | #绘制柱形图 |
plt.title("学习人数最少的 10 个班级") | #设置图表标题 |
plt.show () |
站点序号 | 班次 1 | 班次 2 | 班次 3 | 班次 4 | 班次 5 |
1 | 7:20 | 8:00 | 8:30 | 9:00 | 9:30 |
2 | 7:24 | 8:06 | 8:38 | 9:05 | 9:38 |
3 | 7:28 | 8:13 | 8:48 | 9:15 | 9:44 |
4 | 7:32 | 8:15 | 8:54 | 9:20 | 9:50 |
5 | 7:35 | 8:17 | 9:00 | 9:24 | 10:00 |
6 | 7:37 | 8:20 | 9:05 | 9:28 | 10:17 |
7 | 7:40 | 8:24 | 9:13 | 9:30 | 10:25 |
8 | 7:43 | 8:28 | 9:18 | 9:40 | 10:35 |
9 | 7:50 | 8:30 | 9:25 | 9:43 | 10:55 |
10 | 8:00 | 8:40 | 9:40 | 10:00 | 11:09 |
程序运行效果如图所示:
import csv
f=open("gj.csv","r")
f_csv=csv.reader(f)
time= []
for row in f_csv :
time.append(row)
def change(times): #转换时间的单位为分钟,参数 times 如“6:00”
#times.split(':')表示将字符串 times 按照':'进行分割,返回结果为列表
hours=times.split(' :') [0]
minutes=times.split(' :')[1]
res=①
return res
for i in range(1,len(time)): #将公交时间表中的时刻统一转为分钟单位
for j in range(1,len(time[i])) :
time[i] [j]=change(time[i][j])
now=change(input("乘客您好!请输入当前时刻:"))
p1=int(input("请输入上车站点:"))
p2=int(input("请输入下车站点:"))
n=len(time[0])-1
min=time[p1][1]-now
k=1
for i in range(②):
if time[p1] [i]-now< min or ③ :
min= time[p1][i]-now
k=i
tot=④
print( "最近到站的公交为第"+str(k)+"班次,候车时间为"+str(min)+"分钟,预计您的乘车用时为 "+str(tot)+"分钟。")