Ask Your Question
0

Code and markdown cell

asked 2020-05-09 08:30:22 -0500

Cyrille gravatar image

updated 2020-05-09 09:00:46 -0500

Another perhaps stupid question : can we insert code inside a markdown cell, in such a way it can be evaluated ?

edit retag flag offensive close merge delete

Comments

Do you mean code to be displayed, or code to be evaluated?

slelievre gravatar imageslelievre ( 2020-05-09 08:40:54 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2020-05-09 08:51:58 -0500

slelievre gravatar image

To display code in a Markdown cell in Jupyter, use single backticks for inline code, triple backticks for code blocks.

For example:

In the next cell we will define `square` by

```
def square(x):
    return x * x
```

will render as

In the next cell we will define square by

def square(x):
    return x * x

Some Jupyter Notebook and JupyterLab extensions allow to evaluate code in a Mardown cell in Jupyter. See:

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-05-09 08:30:22 -0500

Seen: 38 times

Last updated: May 09