There is a way to add R code to Markdown (Rmd) by using
```{r}
foo()
```
The result will be shown as a block of code and the output of that code (that will be calculated dynamically).
Can the same thing be done for Python or for that matter any other language?