⊗pyPmLpWC 160 of 208 menu

While Loop Without Counter in Python

In the while loop, you can also perform any operations without a counter, just as long as they are true.

Let's divide the number 10.5 by 2 until the result is less than one. To do this, we need to set the opposite condition - the loop will only work if the number is greater than one:

num = 10.5 while num > 1: num = num / 2 print(num) # 0.65625

Use the while loop to divide 100 by 3 as many times as necessary until the result is less than 20.

Let's say you have a number 1. Use a while loop to multiply it by 2.5 until the result is greater than 20.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline