下面Python代码实现输出如下图形,应该在横线处填入的代码是( )【注:字符串乘以一个正整数,相当于相同字符重复】。


| A. (n % 2 == 1 and i == mid_row) or (n % 2 == 0 and (i == mid_row - 1 or i == mid_row)) |
B. (n % 2 == 0 and i == mid_row) or (n % 2 == 1 and (i == mid_row - 1 or i == mid_row)) |
| C. (n % 2 == 1 and i == mid_row) or (n % 2 == 0 and (i == mid_row or i == mid_row + 1)) |
D. (n % 2 == 1 and i == mid_row) or (n % 2 == 0 and i == mid_row - 1) or (n % 2 == 0 and i == mid_row) |
相似题推荐
下面的Python 代码执行后其输出是( )。
cnt = 0 for i in range(1, 5): for j in range(i): print(j, end = "#") break else: print(i*j)
| A. 0#0#1#0#1#2#0#1#2#3#12 |
B. 0#0#1#0#1#2#0#1#2#3# |
| C. 0# |
D. 1# |
下列Python 代码执行后将输出1#4#9#16#16 。()
for i in range(1, 5): for j in range(1, i + 1): if i * j % 10 == 0: break else: print(i * j, end = "#") else: print(i * j)
| A.正确 | B.错误 |
下面的Python 代码执行将不会有输出,因为内层循环j 总是0 开始,i * j % 10 == 0 将会被满足,执行break,故而不会执行代码中的else 子句部分。()
for i in range(1, 10): for j in range(i): if i * j % 10 == 0: break else: print(i*j)
| A.正确 | B.错误 |
执行下面的Python 代码,其语句print(N) 将被执行0 次或极多次(即死循环)。()
N = input() while N : print(N)
| A.正确 | B.错误 |
下面选择项中,与Python 表达式not (x > 5 and y <= 10)等价的是( )。
| A. x <= 5 and y > 10 |
B. x > 5 or y <= 10 |
| C. x <= 5 or y > 10 |
D. not x > 5 and not y <= 10 |
