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
70 changes: 62 additions & 8 deletions cfu-data-types.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,45 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'name': 'Eva', 'age': 36, 'address': 'Caracas', 'salary': 32000.0, 'expenses': 30000.0}\n",
"Eva who is 36 years old and lives in Caracas has $2,000.0 left from her salary after expenses.\n",
" It is True that she has more than $500 left.\n"
]
}
],
"source": [
"# Your code here\n"
"# Your code here\n",
"personal_information = {'name': '', 'age' : 0, 'address' : '', 'salary': 0.0, 'expenses' : 0.0}\n",
"\n",
"for item in personal_information:\n",
" if item == 'name':\n",
" personal_information[item] = input('Enter your name: ')\n",
" elif item == 'age':\n",
" personal_information[item] = int(input('Enter your age: '))\n",
" elif item == 'address':\n",
" personal_information[item] = input('Enter your address: ')\n",
" elif item == 'salary':\n",
" personal_information[item] = float(input('Enter your salary: '))\n",
" elif item == 'expenses':\n",
" personal_information[item] = float(input('Enter your expenses: '))\n",
"print(personal_information)\n",
"\n",
"remaining_salary= personal_information['salary'] - personal_information['expenses']\n",
"\n",
"if remaining_salary >= 500:\n",
" survivor= True\n",
"# print(\"Yes, you can live on this salary\")\n",
"else:\n",
" survivor = False\n",
"# print(\"You may need a second job\")\n",
"\n",
"# print(personal_information['name'], \"who is\", personal_information['age'], \"old and lives in \", personal_information['address'], \"has\", remaining_salary, \"leftfrom her salary after expenses. It is\", survivor, \"that she has more than $500 left.\")\n",
"print(f\"{personal_information['name']} who is {personal_information['age']} years old and lives in {personal_information['address']} has ${remaining_salary:,.1f} left from her salary after expenses.\\nIt is {survivor} that she has more than $500 left.\")"
]
},
{
Expand Down Expand Up @@ -85,7 +121,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -102,17 +138,35 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 19,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"251\n",
"['some', 'say', 'the', 'world', 'will', 'end', 'in', 'firesome', 'say', 'in', 'icefrom', 'what', 'i’ve', 'tasted', 'of', 'desirei', 'hold', 'with', 'those', 'who', 'favor', 'firebut', 'if', 'it', 'had', 'to', 'perish', 'twicei', 'think', 'i', 'know', 'enough', 'of', 'hateto', 'say', 'that', 'for', 'destruction', 'iceis', 'also', 'greatand', 'would', 'suffice', 'python', 'is', 'awesome!']\n"
]
}
],
"source": [
"# Your code here\n"
"# Your code here\n",
"poem_no_puntuation = poem.replace(',', '').replace('.', '').replace('\"',\"\").replace('\\n',\"\")\n",
"poem_lower= poem_no_puntuation.lower()\n",
"second_string= 'python is awesome!'\n",
"# print(poem_lower)\n",
"new_poem = poem_lower + ' ' + second_string\n",
"print(len(new_poem))\n",
"\n",
"poem_list = new_poem.split(\" \")\n",
"print(poem_list)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
Expand All @@ -126,7 +180,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.13.3"
}
},
"nbformat": 4,
Expand Down