Dim t as Double, n as Integer
t = 0 : n = 0
For i = 1 to 10 step 2
n = n + 1
t = t + n / i
next i
程序运行后,下列表达式的值与t相等的是( )
#数据库中获取数据存储在列表中
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( )
请回答下列问题:
① ② ③
Const n = 5
Dim b(n)As Integer
For i = 1 To 5
b(i)= i
Next i
For i = 1 To 2
For j = n – 1 To I Step -1
If a(b(j))> a(b(j + 1))Then
t = b(j):b(j)=b(j + 1):b(j + 1)= t
End If
Next j
Next i
数组元素a(1)~a(5)的值依次为“35,24,45,16,77”,运行上述程序段后,数组元素b(1)到b(5)的值依次为( )
s=”我爱 13aPP14LE!”
ans=res=""
for x in s:
if "a"<=x<="z":
ans=ans+chr(ord(x)-32)
if "A"<=x<="Z":
ans=ans+chr(ord(x)+32)
if "0"<=x<="9":
res=res+x t=ans+res
print(t)
实现上述功能的VB程序如下:
Dim a(1 To 8)As Integer ‘存储道次编号
Dim b(1 To 8)As Single ‘存储运动员成绩
Dim num As Integer
Private Sub Command1_Click()
Dim i As Integer, j As Integer, k As Integer, p As Integer
Dim t As Single
For i=1 To 7
k=i
For j=i+1 To 8
If Then
k=j
End If
Next j
If k<>i Then
p=a(i):a(i)= a(k):a(k)= p
t=b(i):b(i)= b(k):b(k)= t
End If
Next i
For i=1 To 8
List2.AddItem Str(a(i))&“道:”& Str(b(i))
Next i
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer) ’按回车键录入比赛成绩
Dim cj As Single
If KeyAscii=13 Then ‘是否为回车键
num=num+1
cj=Val(Text1.Text)
If cj>0 And num<=8 Then
a(num)= num
List1.AddItem Str(a(num))&“道:”&Str(b(num))
Else
MsgBox “输入无效”
End If
Text1.Text=“”
End If
End Sub
①将A杯中的酒倒在C杯中 ②将B杯中的水倒在A杯中 ③将C杯中的酒倒在B杯中
S="ABCDEFG"
n=Len(s)
m=Int(Rnd*5+1)
i=0:c=1:ans=""
Do While c<= 3
i=(i+m-1)Mod n+ 1
ans=ans+Mid(s,i,1)
c=c+1
Loop
Text 1.Text=ans
执行该程序段后,文本框中不可能的输出是( )


Private Sub Command1_Click()
Dim x as '定义 x 为整型
x = Val(Text1.Text)
Then '条件语句
Text2.Text=
Else
Text2.Text = Str(0.2 + 0.1 * (x - 3))
End If
End Sub