Lesson 13 of 34

while loop: நிபந்தனை உள்ளவரைwhile Loops: Repeat While True

8 min 25 XP

எத்தனை முறை என்று முன்பே தெரியாதபோது while பயன்படுத்துங்கள். நிபந்தனை True ஆக இருக்கும் வரை loop தொடரும்.

Use while when you don't know in advance how many times to repeat. The loop keeps going while its condition is True.

Example: edit me and press Run

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.

count = count + 1 மறந்துவிட்டால் loop முடிவே இல்லாமல் ஓடும் (infinite loop). அப்படி நடந்தால் Stop பொத்தானை அழுத்துங்கள்.

If you forget count = count + 1, the loop never ends (an infinite loop). If that happens, press Stop.

உதாரணம்: ₹1000 சேமிப்பு மாதம் 10% வளர்ந்தால், ₹2000 ஆக எத்தனை மாதம் ஆகும்?

Example: if ₹1000 of savings grows 10% a month, how many months until it reaches ₹2000?

Example: edit me and press Run

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.

months += 1 என்பது months = months + 1 என்பதன் சுருக்கம்.

months += 1 is short for months = months + 1.

Challenge

+25 XP

while loop பயன்படுத்தி 5 முதல் 1 வரை கீழ்நோக்கி எண்ணி (countdown) ஒவ்வொரு எண்ணையும் தனி வரியில் print செய்யுங்கள். கடைசியில் Go! என்று print செய்யுங்கள்.

Use a while loop to count down from 5 to 1, printing each number on its own line. Then print Go!

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.