12. לולאת היא מהwhile?
•מטאפורה:במבה שקית עם אדם בן:
•יש בשקית40במבה יחידות,בלולאת נמצא אותה לאכול ורוצה במבה שאוהב אדם בןwhile
1. number of bambas = 40
2. while number of bambas >0:
3. take one bamba
4. eat bamba
5. go to step 2
6. put the empty bag away
14. לתוכנה אלגוריתם תרגום
• http://www.codeskulptor.org/#user42_8QlK9bVtEO_8.py
1. Given input X
2. Y = some initial guess for
square root of X
3. Calculate Z=|Y^2-X|
4. while (Z is not small enough)
5. Y=(Y+X/Y)/2
6. Z=|Y^2-X|
7. print Y