Tengo que hacer una tarea que no sabia odio todo

beta
Juanposo 2025-11-05 21:46:46 -03:00
parent 8584d5434c
commit 56eccff819
3 changed files with 194 additions and 19 deletions

View File

@ -0,0 +1,89 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "0a36b114",
"metadata": {},
"outputs": [],
"source": [
"De aquí pa abajo ejercicio 1"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "bfc5ce41",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"False\n"
]
}
],
"source": [
"\n",
"n1 = int(input(\"Ingresa un número\"))\n",
"def valida_numero (a):\n",
" return n1 <= 0\n",
"\n",
"print(valida_numero(n1))\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4e708c7e",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"False\n"
]
}
],
"source": [
"string = input(\"Ingresa un string\")\n",
"n2 = int(input(\"Ingresa un número\"))\n",
"def valida_posicion(a,b):\n",
" v = (b<len(a) and b>=-len(a))\n",
" return v\n",
"print(valida_posicion(string,n2))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e3a0f18b",
"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.14.0"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

View File

@ -227,7 +227,7 @@
},
{
"cell_type": "code",
"execution_count": 70,
"execution_count": null,
"id": "c331f248",
"metadata": {},
"outputs": [
@ -235,12 +235,10 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Anotaciones: DDTLLDTLDLLDT DTLLDTDLTLDTLL LLTLDTLDLTLD DTLDTLDLTLDTL\n",
"24 puntos en el periodo 1\n",
"26 puntos en el periodo 2\n",
"21 puntos en el periodo 3\n",
"25 puntos en el periodo 4\n",
"Total: 96 puntos\n"
"Anotaciones: DLTDLTL DLTDLTL\n",
"13 puntos en el periodo 1\n",
"13 puntos en el periodo 2\n",
"Total: 26 puntos\n"
]
}
],
@ -279,6 +277,7 @@
" # Pide que se ingresen las teclas correctas\n",
" else:\n",
" anotaciones = input(\"Los valores deben ser L, D, T o espacio\")\n",
" anotaciones = anotaciones.upper()\n",
" pos = pos + 1\n",
"periodo = periodo + 1\n",
"total = total + puntos\n",
@ -292,18 +291,6 @@
"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.14.0"
}
},
"nbformat": 4,

View File

@ -0,0 +1,99 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"id": "ba90127a",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Texto decodificado:\n",
"MI PINGA ESTA EN SU MAXIMA EXPRESION\n"
]
}
],
"source": [
"def Valida_Entrada(texto):\n",
" \"\"\"\n",
" Valida que la entrada cumpla las siguientes condiciones:\n",
" - Longitud máxima de 1000 caracteres.\n",
" - Solo contiene letras, dígitos, espacios, comas y/o puntos.\n",
" \"\"\"\n",
" if len(texto) > 1000:\n",
" return False\n",
"\n",
" for c in texto:\n",
" if not (c.isalnum() or c in [' ', ',', '.']):\n",
" return False\n",
"\n",
" return True\n",
"\n",
"\n",
"def Decodifica(texto):\n",
" \"\"\"\n",
" Reemplaza los dígitos por las letras según la tabla:\n",
" 1→I, 3→E, 4→A, 5→S, 7→T, 8→B, 0→O\n",
" \"\"\"\n",
" reemplazos = {\n",
" '1': 'I',\n",
" '3': 'E',\n",
" '4': 'A',\n",
" '5': 'S',\n",
" '7': 'T',\n",
" '8': 'B',\n",
" '0': 'O'\n",
" }\n",
"\n",
" resultado = \"\"\n",
" for c in texto:\n",
" if c in reemplazos:\n",
" resultado += reemplazos[c]\n",
" else:\n",
" resultado += c\n",
" return resultado\n",
"\n",
"\n",
"# -------------------- Programa Principal --------------------\n",
"\n",
"def main():\n",
" texto = input(\"Ingrese el texto codificado: \").upper()\n",
"\n",
" if not Valida_Entrada(texto):\n",
" print(\"Error: la cadena contiene caracteres no permitidos o supera los 1000 símbolos.\")\n",
" return\n",
"\n",
" texto_decodificado = Decodifica(texto)\n",
" print(\"Texto decodificado:\")\n",
" print(texto_decodificado)\n",
"\n",
"\n",
"if __name__ == \"__main__\":\n",
" main()"
]
}
],
"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.14.0"
}
},
"nbformat": 4,
"nbformat_minor": 5
}