19 Apr Saturday 13:00 Python Practice – 23.04.15.
Question:
Continue to program the code we made in the class at the bottom of this page. Try to use for loop to create buttons from 1-9.
Hint:
You can use “for i in range(1, 10):” or “for i in ‘123456789’:” to build these 9 buttons, however, you should thinking of how to use math techniques to solve the row and column.
for example, buttons 1,2,3 are in row 3 and buttons 4,5,6 are in row 2. You should think that int(1/3) is 0 or 1//3 is 0, 2//3 is still 0, 3//3 is 1, 4//3 is 1, 5//3 is 1, 6//3 is 2. Then how can you make 1,2,3 all become 3, while 4,5,6 all become 2?
You should use %(finding division remainder) to solve columns, but how?
Sorry, the comment form is closed at this time.