CSE 1010 Lecture 11: Nested Loops part 1
CSE 1010 verified notes
11/29View all
Document Summary
Farmer has to plant a seed in every square in a 4x3 acre eld. Change each square to a 1: go 1 row at a time, 1 square at a time per row. Store the eld in python so that we can change the value of each square from 0 to 1: f1 is a list of lists. Plantfield calls the plantrow function, and the plantrow function calls the plantsquare function: eld, rownum, and colnum need to be de ned in order for the functions to work. The f1 list has 3 terms, each of which is a list that themselves has 4 terms; len(f1) is 3 even though the eld has 12 squares: plantrow. We know what eld and what row, now we need to plant each square in that row: in order to call plantsquare, colnum still needs to be de ned.