當前位置:編程學習大全網 - 電腦編程 - Python編程題求助

Python編程題求助

代碼如下:

#?輸入數值,輸入值為str,所以使用int轉換成整數

number?=?int(input("請輸入數值:"))?#?數值輸入

print_str?=?''

for?i?in?range(number):?#?遍歷

temp_str?=?''?#?臨時字符儲存變量

for?j?in?range(number?-?i):?#?累加”*“

temp_str?+=?"*"

temp_str?+=?"?"?#?添加間隔空格

print_str?+=?temp_str?#?增加到輸出字符中

print(print_str[:-1])?#?刪除最後壹個無用的間隔空格打印

  • 上一篇:灞橋區最好的公立小學
  • 下一篇:c語言:輸入字母d時打印如下字母形狀。
  • copyright 2024編程學習大全網