“Пример петли” Ответ

В то время как синтаксис петли

while(condition)
{
    //statements
}
Siddhant

в то время как петля

#input                                    # output
a=6                                        quantity of commodity=   
b=int(input("quantity of commodity="))     sampoo 
i=1                                        sampoo
while i <= b :                             sampoo
    if i>a:                                sampoo
        print("hello")                     sampoo
        break                              sampoo
    print('sampoo')                        hello  (it is printed when a<=7) 
    i+=1                                   thank you for coming
print("thank you for coming")

Gr@Y_orphan_ViLL@in##

Что такое петли

# There are 2 types of loops in python
# while loops and for loops
# a while loops continues for an indefinite amount of time
# until a condition is met:

x = 0
y = 3
while x < y:
    print(x)
    x = x + 1

>>> 0
>>> 1
>>> 2

# The number of iterations (loops) that the while loop above
# performs is dependent on the value of y and can therefore change

######################################################################

# below is the equivalent for loop:
for i in range(0, 3):
    print(i)

>>> 0
>>> 1
>>> 2

# The for loop above is a definite loop which means that it will always
# loop three times (because of the range I have set)
# notice that the loop begins at 0 and goes up to one less than 3.
codeconnoisseur

Пример петли

public class Test {

   public static void main(String args[]) {
      int x = 10;

      while( x < 20 ) {
         System.out.print("value of x : " + x );
         x++;
         System.out.print("\n");
      }
   }
}
Important Ibis

Ответы похожие на “Пример петли”

Вопросы похожие на “Пример петли”

Смотреть популярные ответы по языку

Смотреть другие языки программирования