Open study

is now brainly

With Brainly you can:

  • Get homework help from millions of students and moderators
  • Learn how to solve problems with step-by-step explanations
  • Share your knowledge and earn points by helping other students
  • Learn anywhere, anytime with the Brainly app!

A community for students.

could someone help me with the concept behind iteration in python

MIT 6.00 Intro Computer Science (OCW)
See more answers at brainly.com
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Join Brainly to access

this expert answer

SIGN UP FOR FREE
Iteration is the process of performing an action until a certain test is met. For example if you are driving to Grandma's house and she lives at exit 10 then you evaluate each exit to see if it is exit 10 if it not then you continue driving and test the next exit. Here is a quick example using a "while" statement. The interation occurs as I increase the exit until it equals 10 #Are we there yet/ exit = 5 #set starting exit while exit <> 10: #test for exit 10, while exit DOES NOT EQUAL 10 print "Only at exit ", exit, " keep on going" exit = exit +1 #drive to the next exit. #run test again #when test is true print "We are at exit ", exit, "I hope Grandma is home" #This prints when we get to exit 10 #end You can copy this program, save it and run it to see what it outputs./ The ouput should look like this: Only at exit 5 keep on going Only at exit 6 keep on going Only at exit 7 keep on going Only at exit 8 keep on going Only at exit 9 keep on going We are at exit 10 I hope Grandma is home
So basically iterative is using the while sumthing sumthing: do this and recursive is for each of these: do this ? Or have I misunderstood?
No wait, the recursive one modifies what we are working on right? So for problem set three it would change the target string...

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

thank you both for the help
No no no - I'm not helpful. I'm just trying to understand it too. After I posted this I found and read the Wikipedia entry on recursion: http://en.wikipedia.org/wiki/Recursion_%28computer_science%29 It helped me heaps, especially the bit about the Fibonacci function where it's written in both pseudocode and python. So for iterative code you use for: or while: but for recursive you call the function within the function using things like if: elif: and else:
ok well the wikipedia info looks good and rwmuller did a great job

Not the answer you are looking for?

Search for more explanations.

Ask your own question