VisuAlg Web

Tomando Decisões (Se... Então)

No Python, decisões usam if , elif e else , com blocos definidos por identação.

No Python, decisões usam if, elif e else, com blocos definidos por identação.

Exemplo de códigoPython


raining = True

if raining == True:
print("I will take the umbrella!")

print("Leaving home...")
Exemplo de códigoPython


print("Enter your age: ", end="")
age = int(input())

if age >= 18:
print("You are an adult.")
else:
if age >= 12:
print("You are a teenager.")
else:
print("You are a child.")