今天学习了Python第一章,但是很遗憾,我并没有学习完成这一章内容,现在把今天的学习内容写下:
嵌套和可变循环:
猜数小程序:
while guess != secret and tries < 6:
guess = input("what's your guess?")
if guess < secret:
print"Too low,ye scurvy dog!"
elif guess >secret:
print "Too high,landlubber!"
tries =tires+1
一次打印3个乘法表:
for M in range(5,8):
for i in range(1,11):
print i,"X",M,"=",i*M
可变循环:
nM=int (raw_input('how many stars do you want?'))
for i in range (1,nM):
print "*",
可变嵌套循环
numLines=int (raw_input('how many lines do you want?'))
numStars=int(raw_input('how many stars per lines?'))
for i in range (1,numLines):
for i in range (1,numStars):
print'*',
利用双重嵌套循环生成星号块
numBlocks=int(raw_input('how many blocks do you want?'))
numLines=int(raw_input('how many lines do you want?'))
numStars=int(raw_input('how many stars do you want?'))
for i in range (1,numBlocks):
for i in range (1,numLines):
for i in range (1,numStars):
print'*',
网友评论