\n",
" Click to reveal solution
\n",
" key_result_3 = f\"Hello Python {current_version}\"
\n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## π€ Boss level"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"From the examples above, you should already computed the key results. Letβs use the key results here."
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Welcome to CM540\n"
]
}
],
"source": [
"print(key_result_1)"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"None\n"
]
}
],
"source": [
"print(key_result_2)"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"None\n"
]
}
],
"source": [
"print(key_result_3)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Optional: We can store the 3 results into a list:"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [],
"source": [
"results = [key_result_1, key_result_2, key_result_3]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can inspect the list values by typing the variable name in a cell. That works because Jupyter notebook display the result of last line of each cell if it is not a variable assignment."
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"['Welcome to CM540', None, None]"
]
},
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"results"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Final Result"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Once you get the key results correct, you will be able to run the following `final_result` and get the expected result."
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Welcome to CM540! Python was first released in None. None\n"
]
}
],
"source": [
"final_result = f\"{key_result_1}! Python was first released in {key_result_2}. {key_result_3}\"\n",
"print(final_result)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"|Expected Result|\n",
"|---|\n",
"|Welcome to CM540! Python was first released in 1990. Hello Python 3.9|"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Summary\n",
"\n",
"In this notebook, we leanred to store result in **variable**. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Letβs move to the next level: Collection."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.8.5"
}
},
"nbformat": 4,
"nbformat_minor": 4
}