diff --git a/cfu-data-types.ipynb b/cfu-data-types.ipynb index e0fee02..6f37ebc 100644 --- a/cfu-data-types.ipynb +++ b/cfu-data-types.ipynb @@ -49,11 +49,103 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'Ben'} {25} {'washington square 1'} {2500} {1890.76}\n" + ] + } + ], + "source": [ + "# Your code here\n", + "name = input(\"Hello, whats is your name?: \")\n", + "age = int(input(\"Please, add your age: \"))\n", + "address = input(\"What is your address?: \")\n", + "salary = int(input(\"Please enter your monthly salary: \"))\n", + "expenses = float(input(\"Which are your monthly expenses?: \"))\n", + "print({name}, {age}, {address}, {salary}, {expenses})" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "609.24\n" + ] + } + ], + "source": [ + "remaining_salary = salary - expenses\n", + "print(remaining_salary)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "609" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "round_salary = round(remaining_salary)\n", + "round_salary\n" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "is_salary_good = remaining_salary >= 500\n", + "is_salary_good" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Ben who is 25 old, and lives in washington square 1 has 609.24 dollars left from his salary after expenses. \n", + "It is True that she has more than $500 left\n" + ] + } + ], "source": [ - "# Your code here\n" + "print(f\"{name} who is {age} old, and lives in {address} has {remaining_salary} dollars left from his salary after expenses. \\nIt is {is_salary_good} that she has more than $500 left\")" ] }, { @@ -85,7 +177,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 98, "metadata": {}, "outputs": [], "source": [ @@ -102,17 +194,148 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 99, "metadata": {}, "outputs": [], "source": [ - "# Your code here\n" + "# Your code here\n", + "# extraer el texto del poema y quitar los signos de puntuación.\n", + "# concatenar o añadir al poema nuevo texto y almacenarlo en una nueva variable\n", + "# calcular el length de esa nueva variable.\n", + "# dividir toda la variable en listado de strings y guardarlo en una nueva variable y print" + ] + }, + { + "cell_type": "code", + "execution_count": 100, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "some say the world will end in fire some say in ice from what i’ve tasted of desire i hold with those who favor fire but if it had to perish twice i think i know enough of hate to say that for destruction ice is also great and would suffice \n" + ] + } + ], + "source": [ + "poem_reduced = poem.replace(\",\" , \" \").replace(\".\" , \" \").replace(\"\\n\" , \" \").casefold()\n", + "print(poem_reduced)" + ] + }, + { + "cell_type": "code", + "execution_count": 101, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'some say the world will end in fire some say in ice from what i’ve tasted of desire i hold with those who favor fire but if it had to perish twice i think i know enough of hate to say that for destruction ice is also great and would suffice python is awsome!'" + ] + }, + "execution_count": 101, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "poem_plus = poem_reduced + \"python is awsome!\"\n", + "poem_plus" + ] + }, + { + "cell_type": "code", + "execution_count": 102, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "245\n" + ] + } + ], + "source": [ + "print(len(poem_reduced))" + ] + }, + { + "cell_type": "code", + "execution_count": 103, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['some',\n", + " 'say',\n", + " 'the',\n", + " 'world',\n", + " 'will',\n", + " 'end',\n", + " 'in',\n", + " 'fire',\n", + " 'some',\n", + " 'say',\n", + " 'in',\n", + " 'ice',\n", + " 'from',\n", + " 'what',\n", + " 'i’ve',\n", + " 'tasted',\n", + " 'of',\n", + " 'desire',\n", + " 'i',\n", + " 'hold',\n", + " 'with',\n", + " 'those',\n", + " 'who',\n", + " 'favor',\n", + " 'fire',\n", + " 'but',\n", + " 'if',\n", + " 'it',\n", + " 'had',\n", + " 'to',\n", + " 'perish',\n", + " 'twice',\n", + " 'i',\n", + " 'think',\n", + " 'i',\n", + " 'know',\n", + " 'enough',\n", + " 'of',\n", + " 'hate',\n", + " 'to',\n", + " 'say',\n", + " 'that',\n", + " 'for',\n", + " 'destruction',\n", + " 'ice',\n", + " 'is',\n", + " 'also',\n", + " 'great',\n", + " 'and',\n", + " 'would',\n", + " 'suffice']" + ] + }, + "execution_count": 103, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "poem_list = poem_reduced.split()\n", + "poem_list" ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "base", "language": "python", "name": "python3" }, @@ -126,7 +349,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.13.9" } }, "nbformat": 4,