Private Sub Command1_Click()
Dim As Single, b As Single, c As Single, p As Single, s As Single
a≡Val(Text1. Text)
b=Val(Text2. Text)
c=Val(Text3. Text)
p=(a+b+c)/2
If a<=p Or b>=p Or c>=p Then
Label1. Caption="不能构成三角形"
Else
s=Sqr(p*(p-a)*(p-b)*(p-c))*p
Label1. Caption="面积为"& s
End If
End Sub
print(ord(65+i),end=",")
B . for i in [1,2,3]:print(chr(65+i),end=",")
C . i = 0while i < 3:
print(chr(i+65), end= “,”)
i += 1
continue
D . i = 0while i < 3:
print(ord(i+65),end= “,”)
i += 1
def exchange(a,b):
a,b=b,a
return(a,b)
x=10
y=20
x,y=exchange(x,y)
print(x,y)
def fun():
x=6
return x
x=3
print(fun(),x)
则程序执行后输出( )
list1=[1,2,3,4]
del list1[1:3]
print(list1)
list=[1,2,3,4,5,6,7,8,9,0]
list.reverse( )
print(list)
s = "ABCDEF"
For i = 1 To Len(s)
a = Int(Rnd * 3 + 1)
b = Mid(s, a Mod 6 + 1, 1)
ch = ch + Chr(Asc(b) + 32)
Next i
执行该程序后,变量ch的值可能是( )
i=1: n=0: Max=0: Sum=0: c=0
Do While i<=5
n=Int(Rnd*5+1)
If n> Max Then Max= n: Sum= Sum+Max: c=c+1
i=i+ 1
Loop
执行该程序段后,以下变量的值可能为( )
'函数bw功能:若二进制位数不足,通过在前面添"0"使得位数为4的倍数
Private Function bw (x As Integer, y As String) As String
Dim r As Integer, i As Integer
r=x Mod 4
If r<>0 Then
For i=1 To 4-r
y="0"+y
Next i
x= Len(y)
End If
bw=
End Function
Private Sub Command1_Click()
Dim m As String, n As Integer, i As Integer, a As Integer
Dim s As Integer, s1 As String, j As Integer
m= Text1. Text
n=Len(m)
Text2. Text= ""
m= '调整m的位数为4的倍数
For i=1 To n-3 Step 4
s=0
For j=I To i+ 3
a= Val(Mid(m, j, 1))
s=
Next j
If s>= 10 Then
s1=Chr(Asc("A")+s-10)
Else
s1= CStr(s) '函数CStr类似于Str,但无前导空格
End If
Text2. Text= Text2. Text+s1
Next i
End Sub
Private Sub Command1_Click( )
Dim n As Integer,i As Integer,a As Integer,b As Integer
Randomize
n=Val(Text1.Text)
i=
Do While i<=n
a=Int(Rnd*100)
b=Int(Rnd*100)
IfThen
List1.AddItem“(“+Str(i)+”)“+Str(a)+”+“+Str(b)+”=”
i=i+1
End If
Loop
End Sub
maxn=8 #晋级决赛的人数
dic={1:"张无忌",2:"赵敏",3:"周芷若",4:"张三丰",5:"宋青书",6:"金毛狮王",7:"杨逍",8:"小昭"} #字典 dic 存储决赛选手的出场顺序及姓名
score = [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0],[0, 0, 0]] #列表score依次存储每位出场选手的3轮表演得分
#例如score[1][1]存储2号选手第二轮表演得分
i = 0
while i < maxn * 3:
r = i // maxn
order = i % maxn
cj = input("请输入各评委的评分: ") #每位评委的评分之间用空格分隔
list_cj = cj.split()
numlist = list(map(int, list_cj)) #将列表各元素转换成整型并存储在列表
numlist 中 tmp = sum(numlist) - max(numlist )-
tmp_score = tmp / (len(list_cj) - 2)
= tmp_score
print(str(order + 1) + "号选手" + dic[order + 1] + "得分: " + )
i += 1
①请填空,完善该程序实现功能:输入一串字符串(message)和一个数字(key)。对这串字符进行加密(向后移位Key位,只对26个英文字母加密)
注:程序修改时,请把下划线及序号删除,不能删除注释语句。
import math
import random
import os
#定义加密函数,对字母进行加密,即向后移动key位,其他字符不加密。
def cipher(befmessage, key):
aftmessage = ''
for char in befmessage:
if char.isupper(): #对大写字母进行加密
code = ord('A')+(ord(char)-ord('A')+key) % 26
aftmessage = aftmessage+chr(code)
elif char.islower(): #对小写字母进行加密
code = +(ord(char) - ord('a') + key) % 26
aftmessage = +chr(code)
else:
aftmessage = aftmessage+char #字母以外的其他字符不进行加密
return aftmessage
#主程序
message = input('请输入明文:')
key = (input('请输入密钥(整数):')) # 输入数字密钥
secret = cipher(message, )
print('加密后的密文是:',)
# 结束
②编写完成后,原名保存并关闭应用软件。
s1=input("请输⼊明⽂:")
q="1357902468";
s2="" for ch in s1:
if "0"<=ch<="9":
s2+=q[int(ch)]
elif "a"<=ch<="z":
s2+=chr((ord(ch)-ord("a")+2)%26+ord("a"))
else:
print(s2)
s2+=ch
运⾏该程序,输⼊s1的值为“Mike521@qq.com”,则输出结果为( )