我正在寻找最酷的事情,你可以在几行简单的代码。我相信你可以用Haskell用15行写一个Mandelbrot集,但是很难理解。

我的目标是启发学生编程很酷。

我们知道编程很酷,因为你可以创造任何你想象到的东西——它是最终的创意出口。我想激励这些初学者,让他们尽可能多地克服早期学习的困难。

Now, my reasons are selfish. I'm teaching an Intro to Computing course to a group of 60 half-engineering, half business majors; all freshmen. They are the students who came from underprivileged High schools. From my past experience, the group is generally split as follows: a few rock-stars, some who try very hard and kind of get it, the few who try very hard and barely get it, and the few who don't care. I want to reach as many of these groups as effectively as I can. Here's an example of how I'd use a computer program to teach:

Here's an example of what I'm looking for: a 1-line VBS script to get your computer to talk to you: CreateObject("sapi.spvoice").Speak InputBox("Enter your text","Talk it") I could use this to demonstrate order of operations. I'd show the code, let them play with it, then explain that There's a lot going on in that line, but the computer can make sense of it, because it knows the rules. Then I'd show them something like this: 4(5*5) / 10 + 9(.25 + .75) And you can see that first I need to do is (5*5). Then I can multiply for 4. And now I've created the Object. Dividing by 10 is the same as calling Speak - I can't Speak before I have an object, and I can't divide before I have 100. Then on the other side I first create an InputBox with some instructions for how to display it. When I hit enter on the input box it evaluates or "returns" whatever I entered. (Hint: 'oooooo' makes a funny sound) So when I say Speak, the right side is what to Speak. And I get that from the InputBox. So when you do several things on a line, like: x = 14 + y; You need to be aware of the order of things. First we add 14 and y. Then we put the result (what it evaluates to, or returns) into x.

这就是我的目标,有一堆很酷的例子来演示,并在他们玩得开心的时候教他们。我在我室友身上尝试了这个例子,虽然我可能不会把它作为第一课,但她喜欢它,并学到了一些东西。

一些很酷的数学程序,可以做出漂亮的图形或容易理解的形状,这是很好的想法,我将研究这些。这里有一些复杂的actionscript示例,但这有点太高级了,我不能教flash。你还有什么其他的想法吗?


当前回答

我发现最喜欢的(在GWBASIC中)是:

10 input "What is your name ";N$
20 i = int(rnd * 2)
30 if i = 0 print "Hello ";N$;". You are a <fill in insult number 1>"
40 if i = 1 print "Hello ";N$;". You are a <fill in insult number 2>"

我发现初学的学生有一些观念需要修正。

电脑不会读心术。 计算机一次只做一件事,即使它们做得如此之快,它们似乎一次就做完了。 计算机只是愚蠢的机器,只会做被告知的事情。 计算机只能识别特定的东西,而这些东西就像积木一样。 一个关键的概念是,变量是包含一个值的东西,它的名称与该值不同。 你编辑程序的时间和它运行的时间之间的区别。

祝你在课堂上好运。我相信你会做得很好的。

附言:我相信你明白,除了材料和技能,你还在教授一种态度,这也是同样重要的。

其他回答

这是一个Python telnet服务器,它将询问用户名并向他们打招呼。这看起来很酷,因为您正在通过网络从不同的计算机与您的程序通信。

from socket import *
s=socket(AF_INET, SOCK_STREAM)
s.bind(("", 3333))
s.listen(5)
while 1:
   (c, a) = s.accept()
   c.send("What is your name? ")
   name = c.recv(100)
   c.send("Hello "+name)
   c.close()

当我第一次写这个的时候。

10 PRINT "What is your name?"
20 INPUT A$
30 PRINT "Hello " A$
40 GOTO 30

它把人们都惊呆了!电脑记住了他们的名字!

编辑:只是补充一下。如果你能说服一个新程序员,这是他们能做的最酷的事情,他们就会成为优秀的程序员。现在,您几乎可以用一行代码来运行别人编写的库。就我个人而言,这样做绝对不会让我感到满足,也看不到教它有什么好处。

JavaScript的处理呢?我不知道如何处理,但是代码对于它能做的事情来说总是显得相当小,它是非常可视化的,你可以在浏览器中运行它。 http://processingjs.org/exhibition

许多人发现赌博令人兴奋和激励。您可以自己构建一个21点发牌者类,公开一个接口。然后,让孩子们建立一个21点玩家班。

你可以为每个学生的解决方案建立一个图表,显示金钱与时间的关系来激励他们完成任务。

这个系统的美妙之处在于你可以在几周内产生增量解决方案:

最简单的解决方法是总是低于某个水平。这大概有5行代码。

一个更好的解决方案是看看发牌人暴露了什么,并据此调整你的击球。

一个更好的解决方案是考虑到你所拥有的实际卡片——而不仅仅是它们价值的总和。

最终的解决方案可能是记录多手牌的发牌情况。(dealer对象可以对player对象进行dealerisshuffshuffle (int numberofdeck)调用,告诉玩家有多少副牌。)

另一个可能的方向是让游戏更具竞争性——玩家不是通过与庄家对抗来赢钱,而是与其他人的解决方案对抗。当然,为了公平起见,你必须轮换谁先击球。

当我第一次想出bash叉式炸弹的时候,我觉得它真的很可爱。如此简单,但它能做的事情却很整洁:

:(){ :|:& };: