{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "name": "resumen40.ipynb", "provenance": [], "authorship_tag": "ABX9TyNE8pZKxeRjXloTsrvI8g1n", "include_colab_link": true }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" } }, "cells": [ { "cell_type": "markdown", "metadata": { "id": "view-in-github", "colab_type": "text" }, "source": [ "\"Open" ] }, { "cell_type": "markdown", "source": [ "# Condicionales `If`\n", "\n", "```python\n", "if :\n", " \n", "elif :\n", " \n", "elif :\n", " \n", "else:\n", " \n", "```\n", "\n" ], "metadata": { "id": "egDheR29Djzu" } }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "JSh5sv1LDfls" }, "outputs": [], "source": [ "edad = 20\n", "if edad >= 18:\n", " print('Eres mayor de edad.')\n", "elif edad >= 13:\n", " print('Eres un adolescente.')\n", "else:\n", " print('Eres un niño.')" ] }, { "cell_type": "code", "source": [ "ciudades =[\"Roma\", \"Londres\", \"París\", \"Madrid\", \"Berlín\"]\n", "city = \"Austin\"\n", "\n", "if city in ciudades:\n", " print(f\"{city} si se encuentra en la lista de ciudades.\")\n", "else:\n", " print(f'{city} no se encuentra en la lista de ciudades.')" ], "metadata": { "id": "N7mpm8Ev-Nig" }, "execution_count": null, "outputs": [] } ] }