for multiplier in range(5,8):
for i in range(2,11):
print(i,"x",multiplier,"=",i*multiplier)
#可变循环
numstars=int(input("请输入你希望的星:"))
for i in range(1,numstars+1):
print("*")
#可变嵌套循环
numLines = int(input("请输入带星的行有几个"))
numStars = int(input("请输入一行有几颗星"))
for line in range(0,numLines):
for star in range(0,numStars):
print("*",end="")
print()
#先打印 行,打印一行的时候打印星星,打印了规定数量星星后,end=""(python3)换行,再按要求打印下一行。。。。。,最后完成打印到规定的行,即可完成打印
"""numLines = int(input("请输入带星的行有几个"))
numStars = int(input("请输入一行有几颗星"))
for line in range(0,numLines):
for star in range(0,numStars):
print("*",end=""),
print("")"""
numBlock = int(input("有多少白块"))
numLines = int(input("请输入带星的行有几个"))
numStars = int(input("请输入一行有几颗星"))
for block in range(0,numBlock):
for line in range(0,numLines):
for star in range(0,numStars):
print("*",end=""),#这里是打印每行星星的数量
print("")#这里是打印多少行 print("",end="")
print("")#这里是分块 注意缩进的使用 print("")
numBlock = int(input("有多少白块"))
for block in range(1,numBlock+1):
for line in range(1,block*2):
for star in range(1,(block+line)*2):
print("*",end=""),#这里是打印每行星星的数量
print("")#这里是打印多少行 print("",end="")
print("")#这里是分块 注意缩进的使用 print("")
for i in range(1,6): print("Hi,Warrren") print("hi,warren"*6) for i in range(1,8): print print('i=',i) print('hello, how') if i == 3: continue print('are you today') #continue的用法 for i in range(1,6): print('i=',i) print('hello,how') if i ==3: break print('are you today') #break的用法 for i in range (1, 6, 2): print("Hi, Warren") range(8) suzhi = int(input("Which multiplication table would you like?")) for i in range(1,13): print(suzhi,"x",i,"=",suzhi*i) suzhi = int(input("Which multiplication table would you like?")) i =1 while i >0 and i<13: print(suzhi,"x",i,"=",suzhi*i) i = i+1 suzhi = int(input("Which multiplication table would you like?")) while suzhi >0 and suzhi<13: print(suzhi,"x",i,"=",suzhi*i)