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
74 changes: 65 additions & 9 deletions cfu-data-types.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,54 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Joan, who is 37 years old, and lives in Hoppegarten, \n",
" has 1500.0 dollars 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",
"name = input('Please enter your name: ')\n",
"age = None\n",
"while not isinstance(age,int):\n",
" age = input('Please enter your age: ')\n",
" if age.isdigit():\n",
" age = int(age)\n",
"\n",
" \n",
"address = input('Please enter your address: ')\n",
"salary = None\n",
"while not isinstance(salary, float):\n",
" salary = input('Please enter your salary: ')\n",
" if salary.isdigit():\n",
" salary = float(salary) \n",
" \n",
"\n",
"expenses = None\n",
"while not isinstance(expenses,float):\n",
" expenses = input('Please enter your expenses: ')\n",
" if expenses.isdigit():\n",
" expenses = float(expenses) \n",
"\n",
"remaining = round(salary-expenses,1)\n",
"\n",
"if remaining >= 500:\n",
" over_500 = True\n",
"else:\n",
" over_500 = False\n",
" \n",
"print(f'''{name}, who is {age} years old, and lives in {address}, \n",
" has {remaining} dollars left from her salary after expenses. \n",
" It is {over_500} that she has more than $500 left.''')\n",
" \n"
]
},
{
Expand Down Expand Up @@ -85,7 +128,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -102,17 +145,30 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"257\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', 'sufficepython', 'is', 'awesome!']\n"
]
}
],
"source": [
"# Your code here\n"
"# Your code here\n",
"newstring = poem.replace(',','').replace('.','').replace('’','').lower() + 'python is awesome!'\n",
"print(len(newstring))\n",
"poem_list = newstring.split(' ')\n",
"print(poem_list)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
Expand All @@ -126,7 +182,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.11.11"
}
},
"nbformat": 4,
Expand Down