What is the coolest thing you can do in <10 lines of simple code? Help me inspire beginners! [closed] Ask Question

What is the coolest thing you can do in <10 lines of simple code? Help me inspire beginners! [closed] Ask Question

I'm looking for the coolest thing you can do in a few lines of simple code. I'm sure you can write a Mandelbrot set in Haskell in 15 lines but it's difficult to follow.

My goal is to inspire students that programming is cool.

We know that programming is cool because you can create anything you imagine - it's the ultimate creative outlet. I want to inspire these beginners and get them over as many early-learning humps as I can.

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;

物事の順序に注意する必要があります。まず、14 と y を加算します。次に、結果 (評価される値、つまり返される値) を x に格納します。

これが私の目標です。生徒たちが楽しみながら、たくさんのすばらしい例を実演して教えることです。私はこの例をルームメイトに試してみましたが、最初のレッスンとしては使わないかもしれませんが、彼女は気に入って、何かを学んだようです。

クールな美しいグラフや図形を作成するmathematicaプログラムわかりやすいものがよいアイデアだと思うので、検討してみます。ここにいくつかあります複雑なアクションスクリプトの例しかし、それはちょっと高度すぎるので、フラッシュを教えることはできません。他に何かアイデアはありますか?

ベストアンサー1

このコードをブラウザのアドレスバーに入力し、Enter キーを押します。すると、Web ページのすべてのコンテンツを編集できるようになります。

javascript:document.body.contentEditable='true'; document.designMode='on'; void 0

それは私が知っている中で最もクールな「ワンライナー」です =)

おすすめ記事