RU beehive logo ITEC dept promo banner
ITEC 109
2014spring
ibarland

homeinfolabsexamshws
D2LMediaSamples/breeze (snow day)tutor/PIs

lab46
while loops

The variables in a loop

Background: We have seen for-loops:


A growing problem

On Day 0, the virus mutated, and one person was infected. “It's only one person who wants to eat brains — how bad can it be?”, the researchers consoled themselves. But Patient Zed bit another researcher and fled. The next morning, that researcher was also infected, and now there were two Zeta-Omega Mutated Bioform Interferon Entities (which the ridiculously, in their unscientific sensationalism, shortened to "zombie").

Each day, every victim bites one more non-infected person, doubling the number of victims the next morning. Computer modeling can be very helpful, in determining the course of the zombie apocalypse.


YOUR TASK: (not to be checked off — but this will be on a quiz) Re-write countVowels2, which is just like countVowels from lab44—strings as arrays: so-far variables revisited, except that you need use a while loop instead of a for-loop.

Remember: in a while-loop, you need to include the work that python did for you in a for-loop: You'll need to initialize the index-variable (once), and update it (each time through the loop).


1 Well, in every example we've made, the index-variable is an int. But really, in theory you could sequence over any range, not just a range of numbers. For example, for monthLen in (31,28,31,30): is valid python, as is for hue in (black, red, green, makeColor(20,30,40), magenta):. Neat!      

homeinfolabsexamshws
D2LMediaSamples/breeze (snow day)tutor/PIs


©2014, Ian Barland, Radford University
Last modified 2014.Apr.28 (Mon)
Please mail any suggestions
(incl. typos, broken links)
to ibarlandradford.edu
Powered by PLT Scheme