Skip to content

Commit 3cc1fa1

Browse files
committed
Creado con Colaboratory
1 parent c6d3eab commit 3cc1fa1

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

7_Drilling.ipynb

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{
2+
"nbformat": 4,
3+
"nbformat_minor": 0,
4+
"metadata": {
5+
"colab": {
6+
"provenance": [],
7+
"authorship_tag": "ABX9TyNLwWDUL7Dcjsvh/CdWgdZc"
8+
},
9+
"kernelspec": {
10+
"name": "python3",
11+
"display_name": "Python 3"
12+
},
13+
"language_info": {
14+
"name": "python"
15+
}
16+
},
17+
"cells": [
18+
{
19+
"cell_type": "code",
20+
"execution_count": 1,
21+
"metadata": {
22+
"id": "VcqA_qvmNFxa"
23+
},
24+
"outputs": [],
25+
"source": [
26+
"class SalarioFueraDeRango(Exception):\n",
27+
" def __init__(self, salario):\n",
28+
" self.salario = salario\n",
29+
" self.mensaje = f\"El salario ({self.salario}) no se encuentra en el rango de 1000 y 2000.\"\n",
30+
" super().__init__(self.mensaje)"
31+
]
32+
},
33+
{
34+
"cell_type": "code",
35+
"source": [
36+
"def ingresar_salario():\n",
37+
" salario = float(input(\"Ingrese su salario: \"))\n",
38+
" if salario < 1000 or salario > 2000:\n",
39+
" raise SalarioFueraDeRango(salario)\n",
40+
" else:\n",
41+
" print(\"Salario válido.\")"
42+
],
43+
"metadata": {
44+
"id": "Zly0z6AUNJBh"
45+
},
46+
"execution_count": 2,
47+
"outputs": []
48+
},
49+
{
50+
"cell_type": "code",
51+
"source": [
52+
"# Ejemplo\n",
53+
"try:\n",
54+
" ingresar_salario()\n",
55+
"except SalarioFueraDeRango as e:\n",
56+
" print(e.mensaje)"
57+
],
58+
"metadata": {
59+
"colab": {
60+
"base_uri": "https://localhost:8080/"
61+
},
62+
"id": "-2ea-LaQNJFg",
63+
"outputId": "87ea6771-40f6-4e74-93a2-33d3ea7a0667"
64+
},
65+
"execution_count": 4,
66+
"outputs": [
67+
{
68+
"output_type": "stream",
69+
"name": "stdout",
70+
"text": [
71+
"Ingrese su salario: 1500\n",
72+
"Salario válido.\n"
73+
]
74+
}
75+
]
76+
}
77+
]
78+
}

0 commit comments

Comments
 (0)