First time here? Check out the FAQ!

Ask Your Question
0

Code and markdown cell

asked 4 years ago

Cyrille gravatar image

updated 4 years ago

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

Preview: (hide)

Comments

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

slelievre gravatar imageslelievre ( 4 years ago )

1 Answer

Sort by » oldest newest most voted
0

answered 4 years ago

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:

Preview: (hide)
link

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: 4 years ago

Seen: 1,010 times

Last updated: May 09 '20