n=100; sumn=0 #①处
pin14. write_digital(1) #打开输送带控制开关
while True:
d=pin2. read_ digital ( ) #返回装箱状态
if d==1: #②处
sumn=sumn+1
if sumn= =n:
pin14. write_ digital (0) #关闭输送带控制开关
break
sleep (1000) #等待1秒
下列关于上述代码及系统功能描述不正确的是( )
def toStr(n,base):
s = "01"
if n < base:
return s[n]
else:
return ①
n = int(input('请输入正整数:'))
result = toStr(n,2)
print(result)
则代码中①处的语句可为( )
a= 1;b=1 for i in range(2,6): c=a+b a=b b=c print(c) | def f(n): if n==1 or n==2: return 1 else: return f(n- 1)+f(n-2) print(f(6)) |
算法一 | 算法二 |
下列说法正确的是( )
图a | 图b |
import pandas as pd
f = open('newfc.txt', 'r', encoding='utf-8').read() # 读取文件
words = f.split() #利用空格、换行符将字符串 f 分割成列表
counts = {} # 建立空字典,用于存放词语及其出现的次数
for word in words: # 统计其中各词语 (2 个及以上汉字构成) 出现的次数
if :
if word not in counts:
counts[word] = 0
# 利用字典生成相应的 Series ,根据值降序排列
s = pd.Series( ).sort_values(ascending=False)
for i in : # 从高到低输出出现次数最多的10个词语
print(i)
服务器端程序基于Python的FlaskWeb框架编写,使用SQLite3数据库。
from microbit import * #导入micro:bit包
import Obloq #导入IoT(物联网)模块的OBLOQ包
IP=" "
PORT="8088"
SSID="jf"
PASSWORD="pkq88888"
uart.init(baudrate=9600, bits=8, parity=None, stop= 1, tx=pin2, rx=pin1)
while Obloq.connectWifi(SSID,PASSWORD, 10000) != True:
display.show("W")
display.scroll(Obloq.ifconfig( ))
Obloq.httpSet(IP,PORT)
while True:
temp = .read_analog( ) #数据的采集
temp = temp*3.3/ 10.24
display.scroll(str(temp))
errno,resp = Obloq.get(" ?id=1&val="+str(temp), 10000)
if errno == 200:
display.scroll(resp)
else:
display.scroll(str(errno))
sleep(60000)
图 a | 图b |
请回答下列问题:
def Ctime(t):
# 自定义函数 Ctime 功能为将时间转为分钟计存入变量s,代码略。
return s
'''
读取出行记录,存储在列表a中,a[i][0]、a[i][1]、a[i][2]依次存储交通工具类型、票价、乘坐开始时刻。交通工具类型a[i][0]值为0表示地铁,1表示公交车。代码略。
'''
n = len(a)
for i in range(n):
a[i][2] = Ctime(a[i][2])
for i in range(n - 1):
for j in range(n - 1, i, - 1):
if :
a[j], a[j - 1] = a[j - 1], a[j]
# 输出出行记录,代码略。
total = 0
head = tail = 0
q = [- 1] * n
for i in range(n):
if a[i][0] == 0:
total += a[i][1]
tail += 1
else:
while head < tail and q[head] < a[i][2] - 45:
head += 1
if :
total += a[i][1]
else:
print(a[i][2],"时刻使用了优惠券")
print("总共花费为:", total)