#第十一章 嵌套与可变循环 动手试一试
#11-1 第八章中的倒数计数器,修改成可变循环程序,询问用户从哪个数开始计算
import time
count = int (input("Countdown time:How many seconds?请输入从哪个数开始倒数:"))
for i in range(count,0,-1):
print(i)
time.sleep(1)
print("BLAST OFF")
#11-2第八章中的倒数计数器,修改成可变循环程序,询问用户从哪个数开始计算 增加星号
import time
count = int (input("Countdown time:How many seconds?请输入从哪个数开始倒数:"))
for i in range(count,0,-1):
print("i,"*" * i)
time.sleep(1)
print((" ")*(count-2),"BLAST OFF")
#11扩展增加星星,两边同时显示,并居中排列
import time
count = int (input("Countdown time:How many seconds?请输入从哪个数开始倒数:"))
for i in range(count,0,-1):
print(" "*(count-i),"*" * i,i,"*" * i) #增加空格。在for中要是两个变量该如何实现?
time.sleep(1)
print((" ")*(count-2),"BLAST OFF")
#11-1 第八章中的倒数计数器,修改成可变循环程序,询问用户从哪个数开始计算
import time
count = int (input("Countdown time:How many seconds?请输入从哪个数开始倒数:"))
for i in range(count,0,-1):
print(i)
time.sleep(1)
print("BLAST OFF")
#11-2第八章中的倒数计数器,修改成可变循环程序,询问用户从哪个数开始计算 增加星号
import time
count = int (input("Countdown time:How many seconds?请输入从哪个数开始倒数:"))
for i in range(count,0,-1):
print("i,"*" * i)
time.sleep(1)
print((" ")*(count-2),"BLAST OFF")
#11扩展增加星星,两边同时显示,并居中排列
import time
count = int (input("Countdown time:How many seconds?请输入从哪个数开始倒数:"))
for i in range(count,0,-1):
print(" "*(count-i),"*" * i,i,"*" * i) #增加空格。在for中要是两个变量该如何实现?
time.sleep(1)
print((" ")*(count-2),"BLAST OFF")
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/220205/viewspace-2074864/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/220205/viewspace-2074864/