Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions lab_oop.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "644831e8",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<function List.remove_ at 0x0000020E61D4F4C0>\n"
]
}
],
"source": [
"#LAB_OOP\n",
"\n",
"#EJERCICIO 1\n",
"\n",
"class List:\n",
" def remove_(self, integer_list, values_list):\n",
" list=[]\n",
" for num in integer_list:\n",
" if num not in values_list:\n",
" \n",
" list.append(num)\n",
" return list\n",
" \n",
" print(remove_)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f549d6f9",
"metadata": {},
"outputs": [],
"source": [
"#EJERCICIO 2\n",
"\n",
"class List(object):\n",
" def count_spec_digits(self, integers_list, digits_list):\n",
" # your code here\n",
" \n",
" lista = []\n",
" \n",
" for digit in digits_list:\n",
" count = 0\n",
" for num in integers_list: \n",
" count += str(num).count(str(digit))\n",
" lista.append((digit, count))\n",
" \n",
" return lista"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "635b8f30",
"metadata": {},
"outputs": [],
"source": [
"# Ejercicio 3\n",
"\n",
"def ordered_count(inp):\n",
" # Crea un diccionario vacío para almacenar los recuentos de caracteres.\n",
" palabra = {}\n",
" # Itera sobre cada carácter en la entrada.\n",
" for letra in inp:\n",
" # Si el carácter ya está en el diccionario, incrementa su recuento.\n",
" if letra in palabra:\n",
" palabra[letra] += 1\n",
" # De lo contrario, agrega el carácter al diccionario con un recuento de 1.\n",
" else:\n",
" palabra[letra] = 1\n",
" # Convierte el diccionario en una lista de tuplas y devuelve la lista.\n",
" return list(palabra.items())"
]
}
],
"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.11.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}