0% found this document useful (0 votes)
17 views4 pages

C1 W1 Lab01 Python Jupyter Soln

This document serves as an optional lab introduction to Python and Jupyter Notebooks, outlining its goals such as familiarizing users with Jupyter notebooks, differentiating between markdown and code cells, and practicing basic Python. It provides guidance on running code cells and using print statements with f-strings. The lab concludes with a congratulatory note for navigating a Jupyter Notebook.

Uploaded by

1856789asif
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views4 pages

C1 W1 Lab01 Python Jupyter Soln

This document serves as an optional lab introduction to Python and Jupyter Notebooks, outlining its goals such as familiarizing users with Jupyter notebooks, differentiating between markdown and code cells, and practicing basic Python. It provides guidance on running code cells and using print statements with f-strings. The lab concludes with a congratulatory note for navigating a Jupyter Notebook.

Uploaded by

1856789asif
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

{

"cells": [
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"# Optional Lab: Brief Introduction to Python and Jupyter Notebooks\n",
"Welcome to the first optional lab! \n",
"Optional labs are available to:\n",
"- provide information - like this notebook\n",
"- reinforce lecture material with hands-on examples\n",
"- provide working examples of routines used in the graded labs"
]
},
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"## Goals\n",
"In this lab, you will:\n",
"- Get a brief introduction to Jupyter notebooks\n",
"- Take a tour of Jupyter notebooks\n",
"- Learn the difference between markdown cells and code cells\n",
"- Practice some basic python\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"The easiest way to become familiar with Jupyter notebooks is to take the tour
available above in the Help menu:"
]
},
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"<figure>\n",
" <center> <img src=\"./images/C1W1L1_Tour.PNG\" alt='missing'
width=\"400\" ><center/>\n",
"<figure/>"
]
},
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"Jupyter notebooks have two types of cells that are used in this course. Cells
such as this which contain documentation called `Markdown Cells`. The name is
derived from the simple formatting language used in the cells. You will not be
required to produce markdown cells. Its useful to understand the `cell pulldown`
shown in graphic below. Occasionally, a cell will end up in the wrong mode and you
may need to restore it to the right state:"
]
},
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"<figure>\n",
" <img src=\"./images/C1W1L1_Markdown.PNG\" alt='missing' width=\"400\" >\
n",
"<figure/>"
]
},
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"The other type of cell is the `code cell` where you will write your code:"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"This is code cell\n"
]
}
],
"source": [
"#This is a 'Code' Cell\n",
"print(\"This is code cell\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"## Python\n",
"You can write your code in the code cells. \n",
"To run the code, select the cell and either\n",
"- hold the shift-key down and hit 'enter' or 'return'\n",
"- click the 'run' arrow above\n",
"<figure>\n",
" <img src=\"./images/C1W1L1_Run.PNG\" width=\"400\" >\n",
"<figure/>\n",
"\n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"### Print statement\n",
"Print statements will generally use the python f-string style. \n",
"Try creating your own print in the following cell. \n",
"Try both methods of running the cell."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"f strings allow you to embed variables right in the strings!\n"
]
}
],
"source": [
"# print statements\n",
"variable = \"right in the strings!\"\n",
"print(f\"f strings allow you to embed variables {variable}\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"# Congratulations!\n",
"You now know how to find your way around a Jupyter Notebook."
]
}
],
"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.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

You might also like