Hice algo
parent
b555511a90
commit
4d5381dd7f
|
|
@ -0,0 +1,171 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "deaa2247",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"El resultado total es: 271738.0\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Ejemplo del PPT:\n",
|
||||
"# Defino la función\n",
|
||||
"def suma_numeros(a,b):\n",
|
||||
" # Sumo ambos números y devuelvo el resultado al programa principal\n",
|
||||
" return (a+b)\n",
|
||||
"######################################################################\n",
|
||||
"\n",
|
||||
"######### Principal #####################\n",
|
||||
"## Pido al usuario que ingrese dos números\n",
|
||||
"n1 = float(input(\"ingrese el primer número\"))\n",
|
||||
"n2 = float(input(\"Ingrese el segundo número\"))\n",
|
||||
"\n",
|
||||
"## Llamo a la función suma_numeros asignando el resultado total\n",
|
||||
"total = suma_numeros(n1,n2)\n",
|
||||
"\n",
|
||||
"## Muestro el resutado en pantalla\n",
|
||||
"print(\"El resultado total es:\", total)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "f26c8b88",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Su promedio es 73.0 y su situación es: Aprobado\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Otro código ejemplo\n",
|
||||
"def promedio (c1, c2, c3):\n",
|
||||
" suma = c1+c2+c3\n",
|
||||
" pro = round (suma/3,0)\n",
|
||||
" return (pro)\n",
|
||||
"def situacion (x) :\n",
|
||||
" if x<45:\n",
|
||||
" return \"Reprobado\"\n",
|
||||
" elif x<55:\n",
|
||||
" return \"Examen\"\n",
|
||||
" else:\n",
|
||||
" return \"Aprobado\"\n",
|
||||
"\n",
|
||||
"a = int (input (\"Ingrese nota certamen 1: \"))\n",
|
||||
"b = int (input (\"Ingrese nota certamen 2: \"))\n",
|
||||
"c = int (input (\"Ingrese nota certamen 3: \"))\n",
|
||||
"pro = promedio (a,b, c)\n",
|
||||
"resu = situacion (pro)\n",
|
||||
"print (\"Su promedio es\", pro, \"y su situación es:\", resu)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "436edab1",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Ahora vienen los ejercicios siquesi"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"id": "8139098d",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"En Celsius hacen 36.666666666666664 Grados\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"def grados (g1) : \n",
|
||||
" conversion = (g1 - 32) * 5/9\n",
|
||||
" return (conversion)\n",
|
||||
"a = int(input(\"Ingrese grados en Farenheit\"))\n",
|
||||
"C = grados(a)\n",
|
||||
"print(\"En Celsius hacen\", C, \"Grados\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 43,
|
||||
"id": "82524c24",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"El número mayor fue el (75465, 3)\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"n1 = int(input(\"Indique un número\"))\n",
|
||||
"n2 = int(input(\"Indique otro número\"))\n",
|
||||
"n3 = int(input(\"Último número\"))\n",
|
||||
"\n",
|
||||
"def mayor(a,b):\n",
|
||||
" if n1 > n2 and n1 > n3:\n",
|
||||
" num = n1\n",
|
||||
" valor = 1\n",
|
||||
" return(num, valor)\n",
|
||||
" elif n2 > n1 and n2 > n3:\n",
|
||||
" num = n2\n",
|
||||
" valor = 2\n",
|
||||
" return(num, valor)\n",
|
||||
" else:\n",
|
||||
" num = n3\n",
|
||||
" valor = 3\n",
|
||||
" return(num, valor)\n",
|
||||
"\n",
|
||||
"res = mayor(a,b)\n",
|
||||
"print(\"El número mayor fue el\", res)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "ecd75627",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"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.13.7"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "d34cc4f9",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Indicar cuál es el número más grande\n",
|
||||
"n1=int(input(\"Indique un número\"))\n",
|
||||
"n2=int(input(\"Ya dame otro\"))\n",
|
||||
"n3=int(input(\"uno ma uno ma\"))\n",
|
||||
"\n",
|
||||
"if n1 > n2 and n1 > n3:\n",
|
||||
" print(n1, \"es el número más grande\")\n",
|
||||
"elif n2 > n1 and n2 > n3:\n",
|
||||
" print(n2, \"es el número más grande\")\n",
|
||||
"else:\n",
|
||||
" print(n3, \"es el número más grande\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "dd523e0d",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Determinar la hipotenusa y verificar que cumple pitágoras\n",
|
||||
"a = int(input(\"Dame un lado\"))\n",
|
||||
"b = int(input(\"Dame otro\"))\n",
|
||||
"c = int(input(\"Último lado\"))\n",
|
||||
"\n",
|
||||
"if a > c and a > b:\n",
|
||||
" hipotenusa = a\n",
|
||||
"elif b > c:\n",
|
||||
" hipotenusa = b\n",
|
||||
"else:\n",
|
||||
" hipotenusa = c\n",
|
||||
"\n",
|
||||
"print(\"La hipotenusa es\", hipotenusa)\n",
|
||||
"\n",
|
||||
"if (a**2+b**2)==c**2:\n",
|
||||
" print (\"Según los lados ingresados\", a, b, c, \"el triángulo es: rectángulo\")\n",
|
||||
"elif (a**2+b**2) < c**2:\n",
|
||||
" print (\"Según los lados ingresados\", a, b, c, \"el triángulo es: obtusángulo\")\n",
|
||||
"else:\n",
|
||||
" print (\"Según los lados ingresados\", a, b, c, \"el triángulo es: acutángulo\")\n",
|
||||
"\n",
|
||||
"#No me salió lol"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
Loading…
Reference in New Issue