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
75 changes: 65 additions & 10 deletions cfu-data-types.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,43 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 13,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdin",
"output_type": "stream",
"text": [
"What is your name ? Julie\n",
"What is your age ? 23\n",
"What is your address ? Paris\n",
"What is your salary ? 3000\n",
"What is your expenses ? 500\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Julie, who is 23 years old, and lives in Paris has 2500 dollars left from her salary after expenses. It is a good salary that she has more than $500 left.\n"
]
}
],
"source": [
"# Your code here\n"
"list_informations = [\"name\", \"age\", \"address\", \"salary\", \"expenses\"]\n",
"user_info = { info : input(f\"What is your {info} ? \") for info in list_informations}\n",
"int(user_info[\"age\"])\n",
"round(float(user_info[\"salary\"]),1)\n",
"round(float(user_info[\"expenses\"]),1)\n",
"\n",
"remaining_salary = int(user_info[\"salary\"]) - int(user_info[\"expenses\"])\n",
"\n",
"if remaining_salary > 500 :\n",
" is_salary_good = \"a good salary\"\n",
"else : \n",
" is_salary_good = \"a low salary\"\n",
" \n",
"print(f\"{user_info[\"name\"]}, who is {user_info[\"age\"]} years old, and lives in {user_info[\"address\"]} has {remaining_salary} dollars left from her salary after expenses. It is {is_salary_good} that she has more than $500 left.\")\n"
]
},
{
Expand Down Expand Up @@ -85,7 +117,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -102,19 +134,42 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 27,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"258\n",
"['some', 'say', 'the', 'world', 'will', 'end', 'in', 'fire\\nsome', 'say', 'in', 'ice\\nfrom', 'what', 'ive', 'tasted', 'of', 'desire\\ni', 'hold', 'with', 'those', 'who', 'favor', 'fire\\nbut', 'if', 'it', 'had', 'to', 'perish', 'twice\\ni', 'think', 'i', 'know', 'enough', 'of', 'hate\\nto', 'say', 'that', 'for', 'destruction', 'ice\\nis', 'also', 'great\\nand', 'would', 'suffice', 'python', 'is', 'awesome!']\n"
]
}
],
"source": [
"# Your code here\n"
"# Your code here\n",
"ponctuation = [ \".\",\",\",\";\",\"'\",\"!\",\"’\"]\n",
"for p in ponctuation :\n",
" p = poem.replace(p,\"\").lower()\n",
"new_str = (p + \" python is awesome!\")\n",
"print(len(new_str))\n",
"poem_list = new_str.rsplit(\" \")\n",
"print(poem_list)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python [conda env:base] *",
"language": "python",
"name": "python3"
"name": "conda-base-py"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -126,7 +181,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.12.7"
}
},
"nbformat": 4,
Expand Down