examen 1

parent 3b5c1109
...@@ -499,19 +499,17 @@ ...@@ -499,19 +499,17 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 319, "execution_count": 324,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"Solo se leer del 1 al 3999\n",
"Ingresar número (Cero para terminar el programa):10\n", "Ingresar número (Cero para terminar el programa):10\n",
"10:\n", "10:\n",
"X\n", "X\n",
"Ingresar número (Cero para terminar el programa):24\n",
"24:\n",
"XXIV\n",
"Ingresar número (Cero para terminar el programa):0\n" "Ingresar número (Cero para terminar el programa):0\n"
] ]
} }
...@@ -519,22 +517,32 @@ ...@@ -519,22 +517,32 @@
"source": [ "source": [
"enteros= [1000, 900, 500, 400,100, 90, 50, 40,10, 9, 5, 4,1] \n", "enteros= [1000, 900, 500, 400,100, 90, 50, 40,10, 9, 5, 4,1] \n",
"Letras = [\"M\", \"CM\", \"D\", \"CD\",\"C\", \"XC\", \"L\", \"XL\",\"X\", \"IX\", \"V\", \"IV\",\"I\"]\n", "Letras = [\"M\", \"CM\", \"D\", \"CD\",\"C\", \"XC\", \"L\", \"XL\",\"X\", \"IX\", \"V\", \"IV\",\"I\"]\n",
"romano=\"\"\n", "class ejercicio7:\n",
"while True:\n",
" x=int(input(\"Ingresar número (Cero para terminar el programa):\"))\n",
" if(x==0):\n",
" break\n",
" print(str(x)+\":\")\n",
" i=0\n",
" \n", " \n",
" while (x>0):\n", " def informacion(self):\n",
" if(x>=enteros[i]):\n", " print(\"Solo se leer del 1 al 3999\")\n",
" x=x-enteros[i]\n", " \n",
" romano+=Letras[i]\n", " def cambiar(self):\n",
" else:\n", " romano=\"\"\n",
" i=i+1\n", " while True:\n",
" print(romano)\n", " x=int(input(\"Ingresar número (Cero para terminar el programa):\"))\n",
" romano=\"\"" " if(x==0):\n",
" break\n",
" print(str(x)+\":\")\n",
" i=0\n",
" \n",
" while (x>0):\n",
" if(x>=enteros[i]):\n",
" x=x-enteros[i]\n",
" romano+=Letras[i]\n",
" else:\n",
" i=i+1\n",
" print(romano)\n",
" romano=\"\"\n",
" \n",
"x=ejercicio7()\n",
"x.informacion()\n",
"x.cambiar()"
] ]
}, },
{ {
......
...@@ -499,19 +499,17 @@ ...@@ -499,19 +499,17 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 319, "execution_count": 324,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"Solo se leer del 1 al 3999\n",
"Ingresar número (Cero para terminar el programa):10\n", "Ingresar número (Cero para terminar el programa):10\n",
"10:\n", "10:\n",
"X\n", "X\n",
"Ingresar número (Cero para terminar el programa):24\n",
"24:\n",
"XXIV\n",
"Ingresar número (Cero para terminar el programa):0\n" "Ingresar número (Cero para terminar el programa):0\n"
] ]
} }
...@@ -519,22 +517,32 @@ ...@@ -519,22 +517,32 @@
"source": [ "source": [
"enteros= [1000, 900, 500, 400,100, 90, 50, 40,10, 9, 5, 4,1] \n", "enteros= [1000, 900, 500, 400,100, 90, 50, 40,10, 9, 5, 4,1] \n",
"Letras = [\"M\", \"CM\", \"D\", \"CD\",\"C\", \"XC\", \"L\", \"XL\",\"X\", \"IX\", \"V\", \"IV\",\"I\"]\n", "Letras = [\"M\", \"CM\", \"D\", \"CD\",\"C\", \"XC\", \"L\", \"XL\",\"X\", \"IX\", \"V\", \"IV\",\"I\"]\n",
"romano=\"\"\n", "class ejercicio7:\n",
"while True:\n",
" x=int(input(\"Ingresar número (Cero para terminar el programa):\"))\n",
" if(x==0):\n",
" break\n",
" print(str(x)+\":\")\n",
" i=0\n",
" \n", " \n",
" while (x>0):\n", " def informacion(self):\n",
" if(x>=enteros[i]):\n", " print(\"Solo se leer del 1 al 3999\")\n",
" x=x-enteros[i]\n", " \n",
" romano+=Letras[i]\n", " def cambiar(self):\n",
" else:\n", " romano=\"\"\n",
" i=i+1\n", " while True:\n",
" print(romano)\n", " x=int(input(\"Ingresar número (Cero para terminar el programa):\"))\n",
" romano=\"\"" " if(x==0):\n",
" break\n",
" print(str(x)+\":\")\n",
" i=0\n",
" \n",
" while (x>0):\n",
" if(x>=enteros[i]):\n",
" x=x-enteros[i]\n",
" romano+=Letras[i]\n",
" else:\n",
" i=i+1\n",
" print(romano)\n",
" romano=\"\"\n",
" \n",
"x=ejercicio7()\n",
"x.informacion()\n",
"x.cambiar()"
] ]
}, },
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment