蓝桥等考Python组别
九
级
第一部分:选择题
1、Python L
9
(15分)
运行下面程序,可以输出几行
“*”?
( )
for i in range(
3
):
for j in range(
4
):
print('*', end
=
'
')
print()
2
3
4
5
正确答案:B
2
、Python L
9
(15分)
运行下面程序,一共可以输出几个
“*”?
( )
for i in range(
5
):
for j in range(
6
):
print('*', end
=
'
')
print()
30
25
24
20
正确答案:
A
3、Python L
9
(20分)
输出
如下
图形,程序中横线部分应该填( )。
#
# #
# # #
# # # #
# # # # #
for i in range(1, 6):
for j in range(
________
):
print("
#
",
end
=
'
')
print()
6
7
j
i
正确答案:
D
第二部分:编程题
4、Python L
9
方阵图案
(
2
0分)
题目名称:方阵图案
题目描述:
输入一个正整数n,用字符
“
@
”
输出n行n列的方阵
图案
。
提示:
1.print(x, end = ' ')语句可以输出指定内容,以空格结尾;
2.print()语句不输出任何内容,表示换行。
输入:
一个正整数n(
2<=n<=10
)。
输出:
用字符
“
@
”
输出n行n列的方阵
图案
,每行相邻两个字符用一个空格隔开。
注意:
输出时行末尾是否有空格,不影响答案的正确性。
输入样例
1
:
3
输出样例
1
:
@ @ @
@ @ @
@ @ @
输入样例
2
:
4
输出样例
2
:
@ @ @ @
@ @ @ @
@ @ @ @
@ @ @ @
参考程序:
n = int(input())
for i in range(n):
for j in range(n):
print('@', end = ' ')
print()
测试数据:
1.in
3
1.out
@ @ @
@ @ @
@ @ @
2.in
4
2.out
@ @ @ @
@ @ @ @
@ @ @ @
@ @ @ @
3.in
5
3.out
@ @ @ @ @
@ @ @ @ @
@ @ @ @ @
@ @ @ @ @
@ @ @ @ @
4.in
8
4.out
@ @ @ @ @ @ @ @
@ @ @ @ @ @ @ @
@ @ @ @ @ @ @ @
@ @ @ @ @ @ @ @
@ @ @ @ @ @ @ @
@ @ @ @ @ @ @ @
@ @ @ @ @ @ @ @
@ @ @ @ @ @ @ @
5.in
10
5.out
@ @ @ @ @ @ @ @ @ @
@ @ @ @ @ @ @ @ @ @
@ @ @ @ @ @ @ @ @ @
@ @ @ @ @ @ @ @ @ @
@ @ @ @ @ @ @ @ @ @
@ @ @ @ @ @ @ @ @ @
@ @ @ @ @ @ @ @ @ @
@ @ @ @ @ @ @ @ @ @
@ @ @ @ @ @ @ @ @ @
@ @ @ @ @ @ @ @ @ @
5
、Python L
9
棋盘格
(
3
0分)
题目名称:棋盘格
题目描述:
有一个由n*n个小方格组成,黑白交错的棋盘图案。从上面第
1
行开始:
奇数行
从黑色格开始,后面是白黑交替;
偶数
行从白色格开始,后面是黑白交替。
下图是一个5*5的棋盘格。
如果用数字1代表黑,数字0代表白,5*5的棋盘格可以用下面的数字方阵表示。
输入一个正整数n,输出用数字方阵表示的棋盘格。
提示:
1.print(x, end = ' ')语句可以输出指定内容,以空格结尾;
2.print()语句不输出任何内容,表示换行。
输入:
一个正整数n(
2<=n<=10
)。
输出:
n行,每行n个整数,0或者1,相邻两个整数之间用一个空格隔开。
注意:
输出时行末尾是否有空格,不影响答案的正确性。
输入样例:
4
输出样例:
1 0 1 0
0 1 0 1
1 0 1 0
0 1 0 1
参考程序:
n = int(input())
for i in range(n):
for j in range(n):
if (i + j) % 2 == 0:
print(1, end = ' ')
else:
print(0, end = ' ')
print()
测试数据:
1.in
4
1.out
1 0 1 0
0 1 0 1
1 0 1 0
0 1 0 1
2.in
5
2.out
1 0 1 0 1
0 1 0 1 0
1 0 1 0 1
0 1 0 1 0
1 0 1 0 1
3.in
6
3.out
1 0 1 0 1 0
0 1 0 1 0 1
1 0 1 0 1 0
0 1 0 1 0 1
1 0 1 0 1 0
0 1 0 1 0 1
4.in
8
4.out
1 0 1 0 1 0 1 0
0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0
0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0
0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0
0 1 0 1 0 1 0 1
5.in
10
5.out
1 0 1 0 1 0 1 0 1 0
0 1 0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0 1 0
0 1 0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0 1 0
0 1 0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0 1 0
0 1 0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0 1 0
0 1 0 1 0 1 0 1 0 1
蓝桥杯青少组Python组别9级编程练习真题(第4套,共8套)