“для петли” Ответ

для петли

#pass statement and for loop

input:                               output:
number = 0                           result is 1                            
for a in range(14):                  result is 3
    if a%2 == 0:                     result is 5 
        pass                         result is 7
    else:                            result is 9
        print('result is'+str(a))    result is 11 
print('so on')                       result is 13
                                     so on
Gr@Y_orphan_ViLL@in##

для петли

for (int i = 1; i <= 10; i++) {
	printf("%d\n",i);
}
Hard Coder

Что за петли

# 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

для петли

for i in range (some_number):
	#code goes here
Alive Albatross

Ответы похожие на “для петли”

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

Больше похожих ответов на “для петли” по Python

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

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