python倒直角三角形
时间: 2023-09-03 10:16:01 浏览: 303
要打印Python中的倒直角三角形,可以使用以下代码:
```
for i in range(10):
for j in range(i, 10):
print("*", end=" ")
for r in range(0, i):
print(" ", end=" ")
print("")
```
这段代码使用了两个嵌套的循环。外部的循环控制行数,从0到9,内部的循环根据当前行数打印相应数量的星号和空格。循环结束后,打印一个换行符,以换行到下一行。这样就可以得到一个倒直角三角形的形状。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [用python写出各种三角形](https://blog.csdn.net/weixin_45046067/article/details/106911181)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [python使用while、for及循环嵌套实现直角三角形及正、倒金字塔](https://blog.csdn.net/qq_40808154/article/details/89743087)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文