We can figure out that when John walks, it takes him 20 minutes to complete one mile. Therefore, you can start your equation with #T = 20w#, which will tell you how long John spends walking.
To figure out how long John spends running, you then need to find out how many miles he runs by subtracting #w#, the miles he does not run, from #20#, the total miles. Because we don't know what #w# is, we can leave this as an expression. Finally because we can figure out that it takes John 10 minutes to run a mile, so we can multiply #10*(20-w)# and add this on to our equation, giving us #T = 20w + 10(20-w)#, or when simplified, #T = 10w +200#
Another way to solve this equation would be to calculate how long it would take for John to run the entire course by doing #20# miles times #10# mph to get 200. Then, because it takes him #10# minutes longer to walk one mile than to run it, you can simply add #10# minutes for every mile that he walks, leading you to the same final equation of #T = 10w +200#.