{ "cells": [ { "cell_type": "code", "execution_count": 2, "id": "e023841c-63fb-416b-af8c-f7931950c46c", "metadata": {}, "outputs": [], "source": [ "# Introducción a Python\n", "# Tipos de datos en Python\n", "# Como crear variables\n", "# Como usar funciones\n", "# Control + Enter corre cada cell (celda)" ] }, { "cell_type": "code", "execution_count": 3, "id": "d12379a2-4ac2-4442-ad4f-587f184fe547", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "23" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Python es una calculadora\n", "3 + 5 * 4" ] }, { "cell_type": "code", "execution_count": null, "id": "245c5198-7d42-4334-99d3-c4a69935bbc2", "metadata": {}, "outputs": [], "source": [ "# Como agrego cells \n", "# Esc + B agrega una célula abajo\n", "# Esc + A agrega una celda arriba (Ver presentación)" ] }, { "cell_type": "markdown", "id": "639905b9-2bff-4acb-9f76-ff9424b1358b", "metadata": {}, "source": [ "escribir aqui cualquier cosa. Esta es una celda para escribir texto. (MARKDOWN)" ] }, { "cell_type": "code", "execution_count": 5, "id": "75f1ba69-2fe3-4655-88d9-d510973cb979", "metadata": {}, "outputs": [], "source": [ "# asignar valores a una variable\n", "peso = 60 # " ] }, { "cell_type": "markdown", "id": "24112d0d-2498-4654-9211-92ede10ccbf3", "metadata": {}, "source": [ "En Jupyter notebook cada celda puede tener solo texto o ser un código para escribir Python\n", "Una variable puede tener letras, digitos y _ . No puede empezar con un número y son sensible a mayúsculas y minúsculas. peso0 se puede pero no 0peso." ] }, { "cell_type": "code", "execution_count": 6, "id": "653a28e8-2ff9-4564-955a-4370c004335e", "metadata": {}, "outputs": [], "source": [ "peso_kg = 60.3" ] }, { "cell_type": "markdown", "id": "557ade58-87b7-47be-b3c0-fcac1d7ba6bb", "metadata": {}, "source": [ "Python distingue varios tipos de datos. \n", "Integer (Enteros)\n", "Float (Decimales)\n", "String (Texto)" ] }, { "cell_type": "code", "execution_count": 8, "id": "7e0ee522-0b2b-4df7-ae15-4f86d30ef3dd", "metadata": {}, "outputs": [], "source": [ "paciente_id = '001' # en python las comillas definen a una variable como texto" ] }, { "cell_type": "code", "execution_count": 9, "id": "4f4f7708-bf34-4ea4-be50-389ceb139332", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'001'" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "paciente_id" ] }, { "cell_type": "code", "execution_count": 10, "id": "6e3f0af4-1463-4fa7-83b3-f36c3465e85e", "metadata": {}, "outputs": [], "source": [ "peso_lb = 2.2 * peso_kg" ] }, { "cell_type": "code", "execution_count": 13, "id": "c828eaf1-33a1-4f89-8df6-91d965514791", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "132.66\n" ] }, { "data": { "text/plain": [ "3" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "print(peso_lb)\n", "3" ] }, { "cell_type": "code", "execution_count": 14, "id": "c57ef4e7-1c70-4893-8d53-20bc5ad2b471", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "2\n", "3\n" ] } ], "source": [ "# Asignar dos variables al mismo tiempo\n", "a, b, = 2, 3\n", "print(a)\n", "print(b)" ] }, { "cell_type": "code", "execution_count": 15, "id": "5b42f340-dbaf-46cf-b020-099841d91c6a", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "001 peso en kilogramos: 60.3\n" ] } ], "source": [ "print(paciente_id, 'peso en kilogramos:', peso_kg)" ] }, { "cell_type": "markdown", "id": "03eaf992-8117-4d89-9302-0021fd8baffe", "metadata": {}, "source": [ "También puedes llamar a funciones dentro de funciones" ] }, { "cell_type": "code", "execution_count": 18, "id": "275f550d-d2fc-494a-a8a5-953205801d0f", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "\n", "001\n" ] } ], "source": [ "print(type(60.3))\n", "print(type(paciente_id))\n", "print(paciente_id)" ] }, { "cell_type": "code", "execution_count": 19, "id": "088a756f-ee09-40bb-99b5-c2ec30d37618", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "peso en libras: 132.66\n" ] } ], "source": [ "print('peso en libras:', 2.2 * peso_kg)" ] }, { "cell_type": "markdown", "id": "3c3e7384-20e3-44c4-9d74-0ff60107b426", "metadata": {}, "source": [ "El comando anterior NO CAMBIO EL VALOR DE PESO_KG" ] }, { "cell_type": "code", "execution_count": 20, "id": "2b872ee5-09ad-40ab-be13-890defc9c192", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "60.3" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "peso_kg" ] }, { "cell_type": "code", "execution_count": 21, "id": "a135b170-4c58-4d97-b7a6-014af16be8cb", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Douglas Adams\n" ] } ], "source": [ "mi_nombre = 'Douglas Adams'\n", "print(mi_nombre)" ] }, { "cell_type": "code", "execution_count": 23, "id": "676b062e-03f7-4501-a2f2-293c9c2d81f8", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "o\n" ] } ], "source": [ "print(mi_nombre[1])" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.13" } }, "nbformat": 4, "nbformat_minor": 5 }