27分支结构应实例课练
填空题
1变量abc分保存元二次方程二次项次项系数常数项(中a≠0)变量x1x2分保存方程两根完善列程序程序运行时根方程abc值计算根输出相应信息
d=
if d>0 then
x1 (b + Sqr(d)) (2 * a)
x2
text4textstr(x1)
text5textstr(x2)
label6caption两实数根
else
if then
x1=(b)(2*a)
x2x1
text4textstr(x1)
text5textstr(x2)
label6caption两相实数根
else
text4text
text5text
label6caption
end if
end if
2面程序根文框x中输入容进行处理:
x中值246印x值246
x中值1020间数印x值10~20
x中值20数印x 值20
否印x范围
Private Sub Command1_Click()
x Val(Text1Text)
Select Case x
Case
Print x值246
Case
Print x值10~20
Case
Print x值20
Print x范围
End Select
End Sub
3阅读程序写结果
year2021
if (year4000) or ( year40 and year1000 ):
days366
else:
days365
print(days)
⑴程序运行结果:________
a88
b48
cab
If c0:
ca*10+b .
elif 1
elif 10
print(c)
⑵程序运行结果:________
for i in range(1102):
print(iend )
⑶程序段执行结果:________
for i in range(1100):
if i30 and i70:
print(iend )
⑷程序段执行结果:________
二单选题
4度学VB语言程序设计产生浓厚兴趣电脑课度编写图11示汽车停车收费VB程序停车时间12时收费10元停车超12时超1时加收1元聪明度程序进行分析?
1 Dim time price As Integer time代表停车时间price代表停车费
2 time Text1 Text 文框输入停车时间
3 If time < 12 Then
4 price 10
5 Else
6 price 10 + (time 12)
7 EndIf
8 Form1 Print price
图 11
(1)程序第2行time Text1 Text表示VB界面文框中输入停车时间度输入time值8应该缴纳停车费price值( )
A 10 B 18 C 4 D '0
(2)度输入time值16应该缴纳停车费price值( )
A 10 B 14 C 0 D 6
(3)度输入time值1时应该缴纳停车费price值( )
A 0 B 10 C 编译错误 D 12
(4)题中然度输入时间值负数程序然显示需缴纳费程序更合理需修正程序中漏洞停车时间必须0修改正确( )
A 程序第2行改time >0
B 程序第3行改If time>0 and time < 12 Then
C 程序第3行改If time>0 or time < 12 Then
D 程序第5行改Else If time>0 or time < 12 Then
5运行面 Visual Basic程序单击命令钮 Command1出现图示提示信息:出现该错误原( )
Private Sub Command1_Click()
Dim a As Single b As Single
a Val(Text1Text)
b 10
If a > b
b a * a + 2 * b
End If
Label1Caption Str(b)
End Sub
A If语句缺少Then B If语句缺少Else
C 变量a数类型说明错误 D 变量b数类型说明错误
6文框Text1中输入3时执行面程序Y值( )
xVal(Text1 Text)
If x<2 Then
y2
Else
If x<3 Then
y3
Else
y4
End If
End If
A 2 B 3 C 4 D 程序出错没结果
7列Python语法表述正确( )
A if语句while语句中层次语句模块行必须相缩进空格数
B while语句中般循环体中改变判断条件语句否会出现死循环
C Python缩进表达逻辑层次
D else加号
8Python中输入程序:
if int (input ( ) ) 5 0
print(yes)
if int (input ( ) ) 50
print(no)
果输入7输出( )
A Yes B Print C No D Else
9列程序段执行结果 ( )
x5
y6
If Not x>0 Then xy3 Else yx+3
Print xy yx
A 3 3 B 5 9 C 3 3 D 6 5
10图示程序框图判断意输入数x奇偶性中判断框条件( )
A m0 B x0 C m1 D x1
11列程序运行变量y值( )
x10
if x<10:
y10*x
else:
yx*20+10
A 80 B 90 C 100 D 210
12运行该程序输入75输出结果( )
scoreint (input (请输入考试成绩))
if score>90:
print(A)
elif score>80:
print(B)
elif score>70:
print(C)
elif score>60:
print(D)
else:
print(E)
A A B B C C D D
13面程序运行结果( )
i1
sum0
while i<20:
if I 20:
sumsumi
else:
sumsum+i
i +1
print (sum)
A 1 B 6 C 5 D 10
14整型变量a值3b值2列程序段执行整型变量c值( )
If a>5 then
if b<4 then
cab
else
cba
End if
Else
if b>3 then
ca*b
else
c a mod b
End if
End if
A 2 B 2 C 6 D 1
15段VB程序运行变量a值( )
Dim i As Integer a As Integer
i6
a6
If i <6 Then
a a +4
Else
a a 4
End If
A 2 B 10 C 6 D 4
16面程序执行结果( )(提示:Print语句表示输出)
I10
J20
If I>J Then Print I Else Print J
A 10 B 20 C 1020 D 2010
17求1100间偶数请补充完成方框处代码( )
s0
for i in range(101):
If
ss+i
print (s)
A i20 B i20 C i20 D i20
18根图回答面题
(1)Python中运行图中程序结果( )
A 21 15 B 15 21 C 15 0 D 0 21
(2)题中程序( )结构
A 逻辑 B 序 C 循环 D 分支
(3)Python中( )旦创建修改
A 列表 B 元组 C 字典 D 集合
三解答题
19年网络技术迅猛发展网络购物已成热门购物渠道明学网购台中五双运动鞋想五双中选择双购买(原价折扣详见商品折扣表)明预算超200元更省钱请明设计款软件选择购买双运动鞋实惠
商品折扣表:
商品名称
原价
折扣力度
篮球鞋001
488元
4折
篮球鞋002
458元
5折
跑步鞋001
398元
5折
跑步鞋002
358元
6折
徒步鞋001
339元
6折
软件设计求:(图)
①新建VB工程完成折扣商品计算器程序设计工程文件salevbp窗体文件salefrm保存考试目录操作题
②窗体标题折扣商品计算器窗体左边三标签Label1属性商品原价aLabel2属性折扣力度b Label3属性折价格c旁边分三文框Text1商品原价Text2输入折扣力度Text3输出折价格文框右边三标签Label4属性元Label5属性折 Label6属性元
③单击计算钮(Command1)根计算公式相应提示信息显示标签Text3中
计算公式:折价格商品原价*折扣力度果折价格高200元MsgBox函数提示购买果折价格高200元MsgBox函数提示起买起请您放弃请编程实现
④结:适合明运动鞋什请填写商品名称
20设计计算程序该程序户界面设计四文框:文框1(text1语文)文框2(text2数学)文框3(text3英语)文框4(text4均分)三钮:命令钮1(command1清空)命令钮2(command2计算)命令钮3(command4退出)组成程序运行户清钮清文框中显示容计算钮计算三科均成绩单击退出钮退出
答案解析部分
填空题
1 b*b4*a*c(b Sqr(d)) (2 * a)d0 实根
2 Is 246Is > 10 Is < 20者10 To 20Is > 20Case Else
3 36588481 3 5 7 921 42 63 84
二单选题
4 (1)A
(2)B
(3)B
(4)B
5 A
6 B
7 D
8 C
9 A
10 C
11 C
12 C
13 D
14 D
15 A
16 B
17 C
18 (1)B
(2)D
(3)B
三解答题
19
4
结
篮球鞋001
完整程序:
写法1:
Private Sub Command1_Click()
Dim a As Single b As Single c As Single
a Val(Text1Text)
b Val(Text2Text)
c a * b 10
Text3Text Str(c)
If c < 200 Then
MsgBox (购买)
Else
MsgBox (起买起请您放弃)
End If
End Sub
写法2:
Private Sub Command1_Click()
Dim a As Single b As Single c As Single
a Val(Text1Text)
b Val(Text2Text)
c a * b 10
Text3Text Str(c)
If c > 200 Then
MsgBox (起买起请您放弃 )
Else
MsgBox (购买)
End If
End Sub
20 解:程序参考:
Private Sub Command1_Click()
Text1Text
Text2Text
Text3Text
End Sub
Private Sub Command2_Click()
If Text1 Text Or Text2Text Or Text3Text Then
MsgBox 成绩输入全
Else
Text4Text(Val(Text1Text)+Val(Text2Text)+Val(Text3Text))3
End If
Sub End
Private Sub Command3_Click()
Unload Me
End Sub
文档香网(httpswwwxiangdangnet)户传
《香当网》用户分享的内容,不代表《香当网》观点或立场,请自行判断内容的真实性和可靠性!
该内容是文档的文本内容,更好的格式请下载文档