如果要绘制以下图形: * *** ***** ******* ********* *********** 下列( )选项可以完成该任务:
A: for iline in range(7): print(f {'*'*(2*iline-1):^13} )
B: for iline in range(7): for j in range((13-2*iline+1)//2): print(" ",end="") for k in range(2*iline-1): print("*",end="") print()
C: for iline in range(7): str = '*'*(2*iline-1) print(str.center(13))
D: for iline in range(7): str = '*'*(2*iline-1) print( {:^13} .format(str))
A: for iline in range(7): print(f {'*'*(2*iline-1):^13} )
B: for iline in range(7): for j in range((13-2*iline+1)//2): print(" ",end="") for k in range(2*iline-1): print("*",end="") print()
C: for iline in range(7): str = '*'*(2*iline-1) print(str.center(13))
D: for iline in range(7): str = '*'*(2*iline-1) print( {:^13} .format(str))
举一反三
- 已知字符“▼”的Unicode码位为“25BC”。下面的代码,能够正确输出如下图形的是( )。[img=116x123]18032de2fb12d29.png[/img]知识点:for循环。 A: for i in range(4, 0, -1): print(" "*(4-i)+"\u25BC"*(2*i-1)) B: for i in range(4): print(" "*i+"\u25BC"*(7-2*i)) C: for i in range(4): for j in range(i): print(" ",end="") for j in range(7-2*i): print("\u25BC",end="") print() D: for i in range(4): print(" "*(4-i)+"\u25BC"*(2*i-1))
- (多选)已知字符“▼”的Unicode码位为“25BC”。下面的代码,能够正确输出如下图形的是( )。[img=116x123]17e0c817ca58112.png[/img]知识点:for循环。 A: for i in range(4):for j in range(i):print(" ",end="")for j in range(7-2*i):print("\u25BC",end="")print() B: for i in range(4, 0, -1):print(" "*(4-i)+"\u25BC"*(2*i-1)) C: for i in range(4):print(" "*i+"\u25BC"*(7-2*i)) D: for i in range(4):print(" "*(4-i)+"\u25BC"*(2*i-1))
- for i in range(1, 3): for j in range(1, 3): if i * j <; 2: continue print i * j
- 编写一段代码使用for循环输出1~10之内的奇数,以下哪些选项的结果是正确的?( ) A: for i in range(10): if i % 2 == 1: print(i) B: for i in range(9): if i % 2 == 0: print(i) C: for i in range(11): if i % 2 == 1: print(i) D: for i in range(12): if i % 2 = 0: print(i)
- 下列程序的执行结果是( ).for i in range(2): print(i,end=' ' )for I in range(4,6): print(I,end=' ' ) A: 2 4 6 B: 0 1 2 4 5 6 C: 0 1 0 1 2 3 D: 0 1 4 5