“Faça enquanto estiver em Python” Respostas de código

Python faz enquanto

# Python does not have a do-while loop. You can however simulate
# it by using a while loop over True and breaking when a certain
# condition is met.
# Example:
i = 1
while True:
    print(i)
    i = i + 1
    if(i > 3):
        break
SkelliBoi

Como escrever um tempo declaração em python

myvariable = 10
while myvariable > 0:
  print(myvariable)
  myvariable -= 1
Thoughtful Trout

Faça enquanto estiver em Python

There is no direct do while loop in python.
Lala Talishinskaya

python faça enquanto o loop

# A python equivilant to do-while
n = 0
while True: # Do
  print(n)
  n += 1
  if n%3 == 0: # While
    break
# Output: 0, 1, 2
fmoeran

enquanto loop em python

# Program to add natural numbers up to 'n'
# sum = 1+2+3+...+n

n = 10
sum = 0
i = 1

while i <= n:
    sum = sum + i
    i = i+1    # update counter

# print the sum
print("The sum is", sum)

# To take input from the user,
# n = int(input("Enter n: "))
Inquisitive Iguana

Faça enquanto estiver em Python

while True:
    if condition:
        break

Respostas semelhantes a “Faça enquanto estiver em Python”

Perguntas semelhantes a “Faça enquanto estiver em Python”

Mais respostas relacionadas para “Faça enquanto estiver em Python” em Python

Procure respostas de código populares por idioma

Procurar outros idiomas de código