简体   繁体   English

Python逐行可视化工具

[英]Python line-by-line visualization tool

I am teaching programming to first-year students in university. 我正在为大学一年级的学生教授编程。 For this fall we are transitioning from Java to Python as our main language for illustrating concepts, and for student assignments. 今年秋天,我们将从Java过渡到Python,将其作为主要语言来说明概念和学生作业。

I have come here to ask if anyone knows if there exists a tool that can allow students to step through each code line, and answer questions in each step. 我来这里问是否有人知道有没有一种工具可以让学生逐步浏览每行代码,并在每一步中回答问题。 Much like the one pythontutor.com offers, but with the added functionality of being able to ask multiple choice questions for each step. 就像pythontutor.com提供的一样,但具有增加的功能,能够为每个步骤提出多项选择问题。

I apologise if I have come to the wrong place, and would be grateful to be pointed in the right direction. 如果到了错误的地方,我深表歉意,并感谢您指出正确的方向。

I strongly second Right leg's advice. 我强烈赞成右腿的建议。 I've taught an intro-to-CS course to high school students using Python. 我已经为使用Python的高中学生教授了CS入门课程。 We used IDLE, the IDE (if you can call it that?) that Python ships with, and I regret every minute of it . 我们使用了IDLE,即Python附带的IDE(如果您能称呼它吗?), 我对此感到遗憾

Next year I'll write a custom environment for them to make sure things go more smoothly. 明年,我将为他们编写一个自定义环境,以确保一切顺利。 It's actually not so hard to implement such an environment using Python itself (which is precisely what IDLE does IIRC). 实际上,使用Python本身来实现这样的环境并不难(这正是IDLE进行IIRC的目的)。

Making good use of try / except and exec , you can basically 'step through' their code with error checking (and, if you want to get even fancier, global & local variable state information, etc). 充分利用try / exceptexec ,您基本上可以通过错误检查“步入”它们的代码(并且,如果您想获得更高级的,全局和局部变量状态信息等)。 You're also free to do nice, quality-of-life things like check for common problems (using print as a function in Python 2, or as a statement in Python 3) and emit useful error messages! 您还可以自由地做一些生活质量不错的事情,例如检查常见问题(在Python 2中使用print作为函数,或者在Python 3中作为语句使用)并发出有用的错误消息!

I highly-recommend tailoring your environment for your students. 我强烈建议您为学生量身定制环境。 Not only will it likely be superior to the alternatives, but (and the value of this can't be overstated), when things go wrong with their coding environment, you'll know why . 它不仅可能优于替代方案,而且(而且其价值不能夸大),当其编码环境出现问题时, 您会知道为什么 You won't have to dig through someone else's implementation, docs, etc. 您无需深入研究其他人的实现,文档等。

While it doesn't include quizzing, Thonny gives excellent stepping ability (even within expressions!). 虽然不包括测验,但Thonny具有出色的步进能力(即使在表情内也是如此!)。 Thonny屏幕截图

You might also want to look at nbtutor which does pythontutor-like visualisation inside notebooks. 您可能还想看看nbtutor ,它在笔记本内部进行类似于pythontutor的可视化。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM