下面的程序输出如下所示的星号图 案,请在划线处添加适当的语句将 程序补充完整。 ******* n=4 m-0 while n>=1: [项空 print('([填空2],end=") n--1 m 1
时间: 2023-10-21 11:04:10 浏览: 47
下面是补充完整的程序:
```
n = 4
m = 0
while n >= 1:
# 打印空格
for i in range(m):
print(' ', end='')
# 打印星号
for j in range(n):
print('*', end='')
print() # 换行
n -= 1
m += 1
```
输出结果为:
```
*******
*****
***
*
```
相关问题
写一个程序,将闭区间内所有整数用中划线连接保存在字符串类型变量中
以下是 Lua 代码,可以将闭区间内所有整数用中划线连接保存在字符串类型变量中:
```lua
function joinIntegers(start, stop)
local result = ""
for i = start, stop do
if i == start then
result = tostring(i)
else
result = result .. "-" .. tostring(i)
end
end
return result
end
local str = joinIntegers(1, 10)
print(str) -- 输出 "1-2-3-4-5-6-7-8-9-10"
```
希望能帮到你!
5、下面程序运行时输出为:200 20 20,请在划线出填写适当代码。 class test: data=0 x=test() x.data=200 print(x.data,y.data,test.data)
代码如下:
```
class test:
data=0
y = test()
y.data = 20
x=test()
x.data=200
print(x.data, y.data, test.data)
```
输出结果为:`200 20 0`。因为`test.data`是类属性,而不是实例属性。
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)