for x in range(1,4): for o in range(0,x-1): print('*',end='') pass pass print('*') print('\n')print("正方形")for c in range(1,4): for b in range(2): print('*',end='*') pass print('*') pass print("乘法表") for m in range(1,10): for n in range
再重新捡起Python,数据库短时间之内已经没啥看的了,不知道今年结束之前能不能Python入门,一直认为自己是没有编程思想的... 1.九九乘法表 #九九乘法表实现的一种方式之一 def Multiplication_table(): for i in range(1,10): for j in range(1,i+1): print("{0}*{1}={2}" .format (j,i,j*i),end=" ") print(" ") Mul
又把python捡起来了,动手能力偏弱,决定每日一练,把基础打好! ------------------------------------------------------------------------------------------------------- 练习题1:九九乘法表 下面是我的新手写法,哈哈哈 1 for i in range(1,10): 2 for j in range(0,i): 3 print(f"{j+1}*{i}={i*(j+1)} ",end
#打印九九乘法表 for i in range(1,10): s = "" for j in range(1,i+1): s += str(j) + '*' + str(i) + '=' + str(i*j)+ ' ' print(s) 方法2: #打印九九乘法表 for i in range(1,10): for j in range(1,i+1): print('{}*{}={}\t'.format(j,i,i*j),end="") print() 方法3(将打
# 99乘法表 # 顺序 for i in range(1,10): n = 1 while n <= i: print('{}x{}={}'.format(n,i,n*i),end=' ') #end= 取消print自动换行 n += 1 print() #换行 #逆序 n = 9 while n >= 1: i = 1 while i <= n: print('{}x{}={}'.format(i,n,n*i),end=' ') #end= 取消print自动换行 i += 1 p