Visualising Factors
Solution 1:
I am not going to give the complete code, since this is clearly an homework assignment.
But here is a pseudo algorithm that can get you started -
You would need two for loops, one nested inside the other. The first for loop for going over the rows, second inner for loop for going over the columns.
Inside the nested for loop, you would need to check whether the counter for inner for loop is divisible by the counter variable of the outer for loop, if it is you need to print
*
without giving a new line (To do this you can useend=''
argument in Python 3 , or use,
after what you want to print in Python 2), if not divisible print-
.Finally after completing the inner loop, you would need to print another newline, so that the next row starts at next line.
Post a Comment for "Visualising Factors"