我可以用本地python格式编写iPython笔记本吗?

2024-05-20 18:22:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我想写一本iPython笔记本,一套教科书中的问题答案,因为我喜欢这种格式。你知道吗

但我不想离开我的文本编辑器,我希望我最终写的东西是可执行的,因为答案有明确的值,所以我应该能够运行每个“答案”作为一个单元测试。你知道吗

像这样有文化的python环境存在吗?你知道吗

目前我有这个设置,它是原始的python,但我不能嵌入TeX或轻松生成格式良好的文档,这是ipynb非常擅长的。你知道吗

test_question_1():
"""Question: What is the area of a triangle with a base of 3cm and a height of 5cm?

Answer: The general equation for area of a triangle is 0.5*base*height.
"""
   base = 3
   height = 5
   target_answer = 7.5
   assert library.area(base=base, height=height) == answer

Tags: of答案answerbaseis格式ipython笔记本