📚 › Python: the friendliest first language
7. Making decisions
Este artículo se traducirá automáticamente. Por ahora se muestra en inglés.
An if statement runs its block only when the condition is True. elif checks another condition and else handles everything else. Indent the block with four spaces: Python uses indentation to know which lines belong together.
Use == for equal and != for not equal.
Ver ejemplo
marks = 65
if marks >= 80:
print("A")
elif marks >= 50:
print("B")
else:
print("C")
✍️ Ahora te toca
Let temperature = 35. Print hot if it is above 30, otherwise mild.