Callysto.ca Banner

Module 5 Unit 1 - A Closer Look at Cell Types#

Unit Learning Objectives#

By the end of this unit, you will be able to

  • Differentiate between code and markdown cells

  • Troubleshoot cell type errors

Why Learn the Python Programming Language?#

Callysto Interviews

from IPython.display import YouTubeVideo
YouTubeVideo('aijmKLg0UkI')

How do I use Python in a Jupyter Notebook?#

M5_U1 image

As you saw in Module 3, the primary cell types available in a Jupyter notebook are Markdown - for word processing - and Coding - for Python programming. In order to start Python coding in a Jupyter notebook, or anywhere, it’s important to understand a bit of Python syntax and style rules. For Python syntax or lexicon the Python Language Reference Guide is the standard. For Python coding practices, in general, it is best to follow the coding practices of the Python community as closely as possible. The folks who’ve taken the time to develop them have thought much more than any of us about what makes Python code easier to read and PEP 8 (Python Enhancement Proposal) is considered the de-facto style guide of the Python community. A deeper dive into Python syntax and style is outside the scope of this course but we will touch on a few elements to help you get started.

Activity#

In Module 3, you were always working with Markdown text. In order for cells to run as expected, it was important that the cell be set as a Markdown cell. When you are using coding or programming commands, it will be necessary to set the cell type as Code instead of Markdown.

In this example, we have two cells—a markdown cell and a code cell. Neither cell has any content in it.

M5_U1 Code

Do you notice the difference between the way the 2 cell types are displayed? The markdown cell appears as a simple grey box. The code cell is also a grey box, but it is preceded by In [ ]:

You may see some similar syntax/symbols in code cells and markdown cells, however the same symbols will behave differently depending on the cell type. Let’s go back to the Notebook with 2 blank cells - 1 markdown and 1 code.

Type the following into each type of cell in your notebook and then answer the following multiple choice questions below:

  • ##This is a code cell

Callysto.ca License