x=4
ifx==5:
print("优秀")
elif x==4:
print("良好")
elif x==3:
print("及格")
else:
print("不及格")
a=4
s=0
while a>=0:
s=s+a
a=a-1
print(s,a)
Dim x As Integer
x=2
Do while x<=63
x=(x+1)*(x-1)
Loop
Dim x As Interger
x= 1
Do While x < 50
x = ( x + 1 )*( x + 2 )
Loop

① ② ③ ④
说明:text1.text、text2.text、text3.text分别表示a,b,max的值
Private Sub Command1_Click()
Dim a AS Integer, b AS Integer
Dim max AS Integer
a=
b=
If then
Else
End Sub
for I in range(0,9,2):
print("*")
在VB中有三种程序结构,其中的分支结构中有一种多分支结构,可以针对多种情况进行编程。在编写移动的坦克游戏中,其中有这一段代码
|
1 Private Sub Picture1_KeyDown(KeyCode As Integer, Shift As Integer) 2 Select Case KeyCode 3 Case 37 4 Image1.Picture = LoadPicure(App.Path& "\pic\tank1.jpg") 5 If Image1.Left - 20 < 0 Then 6 Image1.Left=0 7 Else 8 Image1.Left= Image1.Left-20 9 End If |
Dim i As interger, a As interger
i=1
a=5
If i>3 Then
a=a+9
Else
a=a+6
End if
s=0
For i=5 to -3 step-6
s=s+i
Next i
a=0
while a<5:
a=a+1
print(a)
s='t1Hr2a3'
s1='' ; s2=''; i = 0
while i < len(s):
if '0'<=s[i]<='9':
s1 = s1 + s[i]
elif 'a'<=s[i]<='z':
s2 = s[i] + s2
i = i + 1
ans = s2 + s1
print(ans)
程序执行后,输出的结果是( )
s="abcdefg"
c=len(s) #len 求字符串长度
for i in range(0,c):
if i<2:
print (chr(ord(s[i])+2),end=" ") # ord()函数是chr()函数配对函数,将字符转ASCII值
else:
print(chr(ord(s[i]) + 3),end=" ")
s=0
for i in range (1,5):
s=s+i
print("i=",i,"s=",s)
a=20
b=2
c=a**b+300
print(c)
x=10
if x>=10:
Value=3*x
else:
Value=5*x+10
s=0; k=1
while (k<=101):