Yahoo Αναζήτηση Διαδυκτίου

Αποτελέσματα Αναζήτησης

  1. In Python, we use the while loop to repeat a block of code until a certain condition is met.

  2. 5 Φεβ 2024 · These eight Python while loop examples will show you how it works and how to use it properly. In programming, looping refers to repeating the same operation or task multiple times. In Python, there are two different loop types, the while loop and the for loop.

  3. In Python programming, we use while loops to do a task a certain number of times repeatedly. The while loop checks a condition and executes the task as long as that condition is satisfied. The loop will stop its execution once the condition becomes not satisfied.

  4. The while Loop. With the while loop we can execute a set of statements as long as a condition is true.

  5. While Loop Example. Example 1: Print the numbers from 1 to 10. i = 1 while i <= 10: print(i, end=" ") # important: increment i i += 1. Output: 1 2 3 4 5 6 7 8 9 10. Example 2: Calculate the sum of natural numbers until the sum becomes greater than 100.

  6. 25 Ιουν 2021 · Python while loop repeatedly executes blocks of code while a particular condition is true. Learn how to run indefinite iteration with Python while loops.

  7. You can use loops to for example iterate over a list of values, accumulate sums, repeat actions, and so on. In Python, you can use for and while loops to achieve the looping behavior. For example, here is a simple for loop that prints a list of names into the console. names = ["Ann", "Sofie", "Jack"] for name in names: print(name)