python multiplication tables with while loops with different starting int -
i need homework. want me make 10x10 multiplication tables using multiple while loops , nesting. want user prompted first number row , column. if give 3 column , 12 row this:
3 4 5 6 7 8 9 10 11 12 -------------------------------------------------- 12| 36 48 60 72 84 96 108 120 132 144 13| 39 52 65 78 91 104 117 130 143 156 14| 42 56 70 84 98 112 126 140 154 168 15| 45 60 75 90 105 120 135 150 165 180 16| 48 64 80 96 112 128 144 160 176 192 17| 51 68 85 102 119 136 153 170 187 204 18| 54 72 90 108 126 144 162 180 198 216 19| 57 76 95 114 133 152 171 190 209 228 20| 60 80 100 120 140 160 180 200 220 240 21| 63 84 105 126 147 168 189 210 231 252
this found internet search help:
row = int(input("enter first row number: " )) while(row <= 10): column = int(input("enter frist column number: ")) while(column <= 10): if(row+column==0): print('{:4s}'.format(''),end = '') #corner elif(row*column==0): print('{:4d}'.format(row+column),end = '') # border else: print('{:4d}'.format(row*column),end = '') # table column=column+1 print() row=row+1
if me thankful
it should more this:
row1 = int(input("enter first row number: " )) column1 = int(input("enter first column number: ")) # todo: print header row in range(row1, row1 + 10): column in range(column1, column1 + 10): # todo
that is, prompt input twice, not (1+n) times, , use built-in function range()
generate lists of rows , columns iterate over.
Comments
Post a Comment