<p>I was taught that there were three main aspects of programming:</p>

<ol>
<li>input-output,</li>
<li>computation, and</li>
<li>logic/control</li>
</ol>

<p>"Hello world" is an "input-output" function, specifically a "print" command. The next thing I would teach is a simple computation, even something like <code>1+1=2</code>.</p>

<p>For example:</p>

<pre><code>X=1
Y=X+X
Print Y
</code></pre>

CC BY-SA 3.0
2017-06-22T23:43:45.020Z
TBH logic/control should come first - but in order to see it happen and make sure it works, you need the I/O too (well, at least the O)
ivanivan
CC BY-SA 3.0
2017-06-11T03:52:47.100Z
2017-06-11T04:03:14.337Z
2017-06-11T04:03:14.337Z
Tom Au
<p>I've always used Hello name" as part of Hello World. It's easy enough for most students and makes the program more fun. After Hello World I use a conversion program. For example Fahrenheit to Celsius. That makes a lot of sense in the US but might not in other countries. But there are many conversions that make local sense in other parts of the world. Pounds Sterling to Euros perhaps. Students often like money problems.</p>

<p>Conversion programs involve both input and output but add the introduction of assignment statements and calculations.  More involved calculations allow for a review of the order of operations (one reason I use Fahrenheit to Celsius). Students get interesting results if they don't set up the formula correctly. </p>

<p>Conversion programs also let one introduce testing early in the game. Sure the program compiled, ran, and gave you an answer but how to you know it is the right answer?</p>

CC BY-SA 3.0
2017-06-22T10:54:15.767Z
2017-06-22T10:54:15.767Z
Alfred Thompson
<p>There's absolutely no reason your first program needs to be <code>"hello world"</code> in the first place. </p>

<p>You can start with values of various kinds, and show how to combine them to create more interesting values. For instance, in <em>How to Design Programs</em>, we start out with numbers, strings, <em>and</em> images. </p>

<p>Pretty quickly students can start to create interesting pictures: e.g., flags of various countries, or a scene (imagine a beach with a tree and a sun). Now they can start to change the size of that flag or parts of that scene (e.g., the sun is at different positions). </p>

<p>Next they can make a function that given a parameter, produces the flag or scene at that time (by using the parameter to calculate the position of the sun). Now they supply this to a function called <code>animate</code> and they have their first animation. From there they can go on to much more sophisticated animations. </p>

<p>In short, we think a rocket launching off a pad — a good metaphor for their education — is a pretty nice follow-up, and not that hard to do. The book's prologue (<a href="http://www.ccs.neu.edu/home/matthias/HtDP2e/part_prologue.html" rel="noreferrer">http://www.ccs.neu.edu/home/matthias/HtDP2e/part_prologue.html</a>) shows this progression.</p>

CC BY-SA 3.0
2017-06-30T01:17:31.960Z
2017-06-30T01:17:31.960Z
Shriram Krishnamurthi
<p>You program with images, create the flags of several countries, then lay them over backgrounds, then animate them, and build up to a game. You can do all that in the first week or so of your course if you have the right curriculum. See, for instance, the prologue of <a href="http://www.ccs.neu.edu/home/matthias/HtDP2e/part_prologue.html" rel="noreferrer"><em>How to Design Programs</em></a> (second edition).</p>

CC BY-SA 3.0
2017-06-03T11:52:59.120Z
If you're at the middle-/high-school levels, take a look at the [Bootstrap](http://www.bootstrapworld.org/) family of curricula. There's something in there for everyone, and cut from the same cloth.
Shriram Krishnamurthi
CC BY-SA 3.0
2017-06-29T12:12:42.937Z
This does not seem like a program that would come right after "Hello World", it seems more complex than that.
thesecretmaster
CC BY-SA 3.0
2017-06-03T01:19:29.380Z
+1 for DrRacket which I love as an environment and would love to teach with some day.
Peter
CC BY-SA 3.0
2017-06-03T00:40:41.627Z
2017-06-03T00:40:41.627Z
Shriram Krishnamurthi
<p>I think that a reasonable next step is showing them variables with an I/O basis. Things like: </p>

<ul>
<li><p>using "Hello, world!" or something similar as a string and printing it</p></li>
<li><p>using integers and showing students the different operators for the language (add/subtract/multiply/divide/modulus division/integer division)</p></li>
</ul>

CC BY-SA 3.0
2017-06-29T02:41:44.083Z
2017-06-29T02:41:44.083Z
cMcNerlin
<h2>Consider also going the other way.</h2>

<p>We often think of teaching from small to big. However it is often possible and beneficial to go from big to small. Bertrand Meyer does this in his course “Touch of Class”.</p>

<p>Provide the students with a working program, have them read the program, make some predictions on what it does, then run it, determine what some of the key grammar/vocabulary does, make predictions on what changes will do, then make changes and re-run. </p>

CC BY-SA 3.0
2017-08-23T14:11:35.393Z
I think this is an important answer.
Ben I.
CC BY-SA 4.0
2022-01-10T03:12:05.240Z
But there are quite some preconditions before this can happen.
Qiulang 邱朗
CC BY-SA 3.0
2017-08-23T12:08:34.597Z
2017-08-23T12:08:34.597Z
ctrl-alt-delor
<p>The next step is to introduce the type system.  Students need to know what kinds of data are "understood" by a language.  The "Hello World" program gets the ball rolling because you can ask, "How is text stored? Are there other types of data that can be stored as well?"</p>

CC BY-SA 3.0
2017-06-02T12:41:34.363Z
2017-06-02T12:41:34.363Z
ncmathsadist
<p>I found 'FizzBuzz' really helpful as the next exercise, it has conditions, loops and it also allows you to explain some coding practices, especially DRY (Don't Repeat Yourself).</p>

<p>"Write a short program that will simulate playing FizzBuzz.
The rules are simple:</p>

<ul>
<li>Count from 1 to 100 and print the numbers on screen</li>
<li>If the number is divisible by three, print Fizz instead of the number </li>
<li>If the number is divisible by five, print Buzz</li>
<li>If the number is divisible by both three and five, print FizzBuzz</li>
</ul>

<p>Write as few lines of code as possible."</p>

<p>This is also an exercise that was used a lot on job interviews to determine if someone could actually code and apply good practices. </p>

<p>And for an in-depth explanation on what constitutes a good result: 
<a href="https://www.youtube.com/watch?v=QPZ0pIK_wsc" rel="nofollow noreferrer">Tom Scott: FizzBuzz</a></p>

CC BY-SA 3.0
2017-08-23T14:11:14.503Z
Nice! And welcome to [cseducators.se]. I hope we hear more from you!
Ben I.
CC BY-SA 3.0
2017-08-23T13:36:21.120Z
2017-08-23T13:42:03.567Z
2017-08-23T13:42:03.567Z
Stephan Ghequiere
<p>I agree with the answer proposing Hello name, and the answer that proposes students inputting their name and then repeating it x times. Then a conditional can be introduced that does or does not print their name depending on some boolean expression or similar. At this point, we would have introduced: types, input (and output), repetition, conditionals, and possibly some mathematics. </p>

CC BY-SA 3.0
2017-06-07T04:23:40.813Z
2017-06-07T04:23:40.813Z
Brett Becker
<p>I very much like "The Devil and Daniel Webster", as introduced to me by Devika Subramanian. It connects programming to mathematics, and introduces lists, loops, and if conditions in a fairly simple wait, with an interesting story.</p>

<p>The lecture notes I've found for them are below, but the problem is:</p>

<blockquote>
  <p>The devil made a proposition to Daniel Webster. The devil proposed paying Daniel for services in the following way:"On the first day, I will pay you \$1,000 early in the morning. At the end of the day, you must pay me a commission of $100. At the end of the day, we will both determine your next day's salary and my commission. I will double what you have earned at the end of the day, but you must double the amount that you pay me. Will you work for me for a month?""</p>
</blockquote>

<p><a href="https://sites.google.com/site/publiccomp140site/week-1/the-devil-and-daniel-webster-lecture-notes" rel="nofollow noreferrer">https://sites.google.com/site/publiccomp140site/week-1/the-devil-and-daniel-webster-lecture-notes</a></p>

CC BY-SA 3.0
2017-06-30T12:25:56.390Z
I don't entirely understand the problem. Do we have some way of determining what D.W. will earn? I'm any case, welcome to [cseducators.se]!
Ben I.
CC BY-SA 3.0
2017-07-01T21:23:35.510Z
It's just the payout minus the commission: so 900 for the first day.
sfogarty
CC BY-SA 3.0
2017-07-01T21:25:11.270Z
So, on the second day, he would earn \$1,800, but have to pay \$200?
Ben I.
CC BY-SA 3.0
2017-07-02T22:06:45.897Z
Exactly. Have them turn it into a pair of formulas for each day with subscripted variables.

Then we start writing code, and see that we'd end up with 60-odd variables. Introduce lists as a way of having variables with subscripts. 

Then build up lists manually a few times, and introduce them to for loops. 

Then at the end you can use an if, outside the loop, to check the final values. 

Lists, for loops, and if statements. For my non-majors class it takes three 70-minute classes to get through, but it presents a coherent (if fanciful) problem to motivate them.
sfogarty
CC BY-SA 3.0
2017-06-30T07:51:48.983Z
2017-06-30T07:51:48.983Z
sfogarty
<p>You might find some more ideas here:</p>

<ul>
<li><a href="https://cseducators.stackexchange.com/questions/2793/order-to-teach-topics-in-an-intro-programming-class/2798#2798">Order to Teach Topics in an Intro Programming Class</a></li>
<li><a href="https://cseducators.stackexchange.com/questions/2903/the-order-of-subjects-in-beginners-curriculum/2924#2924">The order of subjects in beginner&#39;s curriculum</a></li>
</ul>

<p>My approach is designed for <a href="http://processing.org" rel="nofollow noreferrer">Processing</a>, but hopefully it generalizes to other languages.</p>

<p>Hello World is really a lesson in <strong>how to call functions</strong>. After they understand the basics, I'd show them how to lookup other functions in either the language reference or in a beginner-friendly list that you give them. In Processing, I'd have them draw a circle or a rectangle, or an entire scene using basic function calls. If your hello world is a console application, then maybe have them display a popup box, or display a message in a window. The specifics of this depend on the language you're using, but the idea is to get them looking stuff up in a reference and playing around with their own code.</p>

<p>From there I'd go to <strong>using variables.</strong> This is different than creating variables. Instead of having students create variables, have them look up whatever predefined variables your language offers. Processing has <code>width</code> and <code>height</code> variables, so I'd have them make their scene scale to the size of the window. But you would use whatever variables your language exposes. Again, have them look stuff up in the reference or in a list you provide them.</p>

<p>From there I'd have them create their own variables and their own functions, which I've explained in more detail in the above questions. But if you're just looking for a follow-up to Hello World, I'd use the above approach of revealing more of the reference and asking them to do their own projects based on what they just learned.</p>

CC BY-SA 3.0
2017-08-23T20:28:13.447Z
2017-08-23T20:28:13.447Z
Kevin Workman
<h3>Existing answers have great suggestions...</h3>
<p>There are many wonderful answers here, and I agree that, in general, <code>&quot;hello ${name}&quot;</code> to introduce dynamic input/output and string concatenation (a natural lead-in to <code>if</code>/<code>else</code> and something like a small quiz app), currency/temperature convertors to introduce mathematical operations and types are great second tasks. A temperature converter with hardcoded values is a refactor away from collecting input, introducing functions, conditions (prompt for Fahrenheit to Celsius or vice-versa) and loops (prompt for multiple temperature conversions).</p>
<p>I also like the idea of <a href="https://cseducators.stackexchange.com/a/3295/9426">prematurely showing students code from a larger project they aren't expected to understand</a>, with the idea of making a few small modifications and exposing them to the look and feel of the sort of applications they'll soon be creating. There's a risk of intimidation, so care would need to be taken, and eventually you'll have to pull back to a &quot;next hello world&quot;-sized step anyway.</p>
<h3>... but what about audience, context and goals?</h3>
<p>However, these answers seem to assume an audience of entry-level programming students. As <a href="https://cseducators.stackexchange.com/questions/349/what-program-follows-hello-world/1257#comment14636_349">pointed out in the comments</a>, plenty of advanced tutorials and courses might begin with a &quot;hello world&quot;-style task.</p>
<p>For example, in back end web development, any first-time Ruby on Rails tutorial will begin with getting the &quot;Congratulations! You're on Rails!&quot; screen up on localhost. For machine learning libraries, a classifier using the iris dataset is a canonical first order of business.</p>
<p>The point here is that audience, language, framework and context matters in choosing a second task, and &quot;hello world&quot; isn't exclusive to beginning programmers or console-based contexts.</p>
<p>With that in mind, a few answers recommend FizzBuzz after &quot;hello world&quot;. Initially, this struck me as rushing in too many fresh concepts that can take time for beginners to grasp: loops, booleans, branching and string manipulation. But if the audience has prior programming experience, FizzBuzz might be a reasonable difficulty for them. And if not, you can always build up, adding the conditions slowly, then the loop.</p>
<p>I recently began learning Haskell from &quot;hello world&quot;, and found that I wrote a dozen or so smaller programs before I was able to write a FizzBuzz that accepted input, to cite an example of the language factor.</p>
<p>Working backward from the goals of the course, the next step.</p>
<p>I'll continue onward assuming beginners, though, since follow-ups to &quot;hello world&quot;s for experienced developers looking to learn the latest framework would be a case-by-case basis.</p>
<p>In any situation, working backward from the goals of the course, the next step after &quot;hello world&quot; might become obvious.</p>
<hr />
<h3>A &quot;10 PRINT&quot; approach</h3>
<p>Answers so far mostly offer a command-line style, general-purpose task that would work in basically any language. But many languages (particularly educational ones like Racket, Scratch and BASIC) offer interesting features that make it easy to do relatively engaging and powerful things without much effort. One suggestion is to try to find and exploit these in whatever environment you're working in. In particular, I find that graphical programs, and particularly animations, are a great way to engage students, even if only ASCII.</p>
<p>A classic example is <a href="https://www.10print.org/" rel="nofollow noreferrer">10 PRINT</a>, a simple BASIC program that produces a <a href="https://www.youtube.com/watch?v=m9joBLOZVEo" rel="nofollow noreferrer">cool animation</a></p>
<pre><code>10 PRINT CHR$(205.5+RND(1)); : GOTO 10
</code></pre>
<p>10 PRINT is not always as easy to achieve in other languages and environments (it exploits aesthetics of the environment's screen, native text wrapping, an easy-to-write infinite loop, and an easy-to-call random number generator), but there's often some other &quot;hack&quot; that happens to create a disproportionately cool effect of some sort in your language.</p>
<p>For most scripting languages, it's pretty easy to provide boilerplate to do animations. In Python:</p>
<pre class="lang-py prettyprint-override"><code>from time import sleep

while True:
    print(&quot;hello world!&quot;)
    sleep(1)
</code></pre>
<p>Working with this basic framework, you can introduce numbers, math operations and string manipulation to add dynamism to the animation (and later on, explain the loop and import in more detail; it's good early exposure):</p>
<pre class="lang-py prettyprint-override"><code>from time import sleep

i = 0
while True:
    print(i % 10 * &quot;@&quot;)
    i += 1
    sleep(0.1)
</code></pre>
<p>The <code>*</code> operator in Ruby and Python and <code>x</code> in Perl shows another easy trick for one-upping &quot;hello world&quot;. String repeat functions, when available, are fantastic: <a href="https://www.destroyallsoftware.com/talks/wat" rel="nofollow noreferrer"><code>&quot;Na&quot; * 10 + &quot; Batman!&quot;</code></a>. This works great with the <a href="https://cseducators.stackexchange.com/a/355/9426">print your name suggestion</a> elsewhere in the thread.</p>
<p>We can try 10 PRINT in Python (although the results won't be too impressive without the C64 monitor; consider adjusting terminal color and typeface prior to the session):</p>
<pre class="lang-py prettyprint-override"><code>from time import sleep
from random import choice

while True:
    print(choice(r&quot;\/&quot;), flush=True, end=&quot;&quot;)
    sleep(0.01)
</code></pre>
<p>or print the <code>&quot;\b&quot;</code> character to make a little animation in-place:</p>
<pre class="lang-py prettyprint-override"><code>from itertools import cycle
from time import sleep

for c in cycle(&quot;what's up?&quot;):
    print(c, flush=True, end=&quot;&quot;)
    sleep(0.5)
    print(&quot;\b&quot;, end=&quot;&quot;)
</code></pre>
<p>or:</p>
<pre class="lang-py prettyprint-override"><code>for s in cycle((&quot;hello&quot;, &quot;world&quot;)):
    print(s, flush=True, end=&quot;&quot;)
    sleep(1)
    print(&quot;\b&quot; * len(s), end=&quot;&quot;)
</code></pre>
<p>Even if students won't understand the code out of the box, they can play around with the string contents and speed, building intuition for what the shape of the code looks like and how it can create something dynamic and interesting with just a few lines.</p>
<p>Al Sweigart has a repository of <a href="https://github.com/asweigart/scrollart" rel="nofollow noreferrer">scroll art</a> scripts for further inspiration, although most are more than a step after &quot;hello world&quot;.</p>
<h3>Other ideas</h3>
<p>Many languages have <a href="https://en.wikipedia.org/wiki/Turtle_graphics" rel="nofollow noreferrer">turtle</a> or <a href="https://cseducators.stackexchange.com/a/3305/9426">another minimal graphics library</a> that lets you draw a circle with 2-3 lines of code and might be a great next step after &quot;hello world&quot;. This is a great choice for students coming from a Scratch background who may be prone to frustration at the relative difficulty of doing anything &quot;fun&quot; with text-based languages.</p>
<p>In HTML, I find that a <code>&lt;pre&gt;</code> tag can open a world of creative options for <a href="https://en.wikipedia.org/wiki/ASCII_art" rel="nofollow noreferrer">ASCII art</a> without having to learn coding concepts immediately, similar to stacking a bunch of <code>print</code> statements or a multiline string to create an <a href="https://en.wikipedia.org/wiki/FIGlet" rel="nofollow noreferrer">ASCII banner</a>.</p>
<p>The nonstandard <a href="https://en.wikipedia.org/wiki/Marquee_element" rel="nofollow noreferrer"><code>&lt;marquee&gt;</code></a> tags, although technically horrible, helped turn my generation on to web development, and are a great way to jazz up &quot;hello world&quot; (when supported). Sure, HTML is probably not relevant for most curricula here, but concepts like this can often inspire ideas for other languages.</p>
<p>CSS offers powerful animation and transition techniques with just a line or two of code. For example, providing something like</p>
<pre class="lang-html prettyprint-override"><code>&lt;style&gt;
body {
  transition: all 2s;
}
body:hover {
  background: black;
}
&lt;/style&gt;
</code></pre>
<p>can get students interacting with their app and provides a foundation for adding CSS properties, creating new elements and designs.</p>
<p>For front-end JS, students can easily use the browser's development tools to manipulate content on Wikipedia or another popular website. For example, without writing code, they can change text to humorous effect while being exposed to the syntax and structure of HTML.</p>
<p>If you don't mind sharing code students might not understand at first but will surely get a kick out of, you can try something like:</p>
<pre class="lang-js prettyprint-override"><code>document.querySelectorAll(&quot;*&quot;).forEach(e =&gt; {
  e.style.background = &quot;#&quot; + Math.random().toString(16).slice(-6);
});
</code></pre>
<p>which sets all element backgrounds to random colors on a page, creating a glitchy art effect and hopefully giving students an idea of what's possible in the spirit of 10 PRINT. Snippets like these can open up conversations about <a href="https://en.wikipedia.org/wiki/Creative_coding" rel="nofollow noreferrer">creative coding</a>, <a href="https://en.wikipedia.org/wiki/Computer_art" rel="nofollow noreferrer">computer art</a> and <a href="https://en.wikipedia.org/wiki/History_of_personal_computers" rel="nofollow noreferrer">history</a> (even if those aren't the focus of the course).</p>
<h3>It's OK to make a mess</h3>
<p>Following the <code>&lt;marquee&gt;</code> principle, in most cases, it should be fine at this stage to let students make a mess and have fun, duplicate code everywhere, then enforce better software engineering principles later. Ugly and outside-the-box is encouraged. For web programming, grabbing snippets from <a href="https://www.w3schools.com/" rel="nofollow noreferrer">w3schools</a> is OK.</p>
<p>For example, I've seen students push a few of their laptops together in a row and sync up the timing of their animations to make it look like text is scrolling between monitors! Encouraging creative, emergent collaboration among students and the tools in the environment enables students to create interesting experiences even with small amounts of code, as 10 PRINT does by exploiting aesthetic qualities of typeface and monitor.</p>

CC BY-SA 4.0
2021-11-06T19:34:29.420Z
2022-01-06T20:50:32.493Z
2022-01-06T20:50:32.493Z
ggorlen
<p>Historically, <code>Hello, &lt;name&gt;</code>, but I think I'm going to go with something like hangman, snake, guess the number... I'm leaning more and more to "hacking" existing programs rather than learning bit by bit. </p>

CC BY-SA 3.0
2017-06-06T17:00:33.963Z
2017-06-06T17:00:33.963Z
Oli Howson
<p>You say you're looking for a program</p>
<blockquote>
<p>that builds upon the basics of printing one line on the screen.</p>
</blockquote>
<p>I don't look at &quot;hello world&quot; as a basis to build upon. It's more of a sanity check: can the student use an editor, compile, run a program. The next program does not need to build on it per se.</p>
<p>So for my students the next step is the &quot;<a href="https://en.wikipedia.org/wiki/Collatz_conjecture" rel="nofollow noreferrer">Collatz conjecture</a>&quot;. For that</p>
<ol>
<li>They need expressions: <code>3*n+1</code>, <code>n/2</code></li>
<li>Conditionals: `if (n%2==0) n=n/2; else n=3*n+1;</li>
<li>Loop: `while (n!=1) /* the above */</li>
<li>Nested loops: find the starting point (say under 1000) with maximum length.</li>
</ol>
<p>And those do all built on each other. Prime number testing/finding is also a good one.</p>

CC BY-SA 4.0
2022-01-07T17:57:04.837Z
2022-01-07T17:57:04.837Z
Victor Eijkhout
<p>After "Hello World" it becomes "Hello \$name" where \$name is provided by user.  After basic I/O and "it compiles and runs", then it is time for loops and logic.  I typically like a variation on fizzbuzz:</p>

<blockquote>
  <p>Print the numbers 1 through 100, if the number is evenly divisible by 3 print "fizz" next to the number, if evenly divisible by 5 print "buzz" next to the number, if evenly divisible by both 3 and 5 then print "wahoo!" next to the number.</p>
</blockquote>

CC BY-SA 3.0
2017-06-15T00:29:47.913Z
2017-06-16T19:43:30.307Z
2017-06-16T19:43:30.307Z
ivanivan
<p>When I was teaching and mentoring first-time students, what got them <strong>really excited for the first time</strong> was seeing their name in lights. Write a program that allows a student to enter their name, then print it on the screen 10 times (or 10,000).</p>

<ul>
<li>It introduces the concept of <strong>variables and variable types</strong></li>
<li>It shows how computers interact with the outside word by <strong>accepting input</strong> from the students</li>
<li>It introduces <strong>basic looping and conditional statements</strong> in a really simple example</li>
<li>It shows how <strong>math and computation</strong> works in a computer without simply spitting out basic algebra. </li>
</ul>

<p>The best part is the students don't have to understand 100% of the program to start picking out the individual parts. The basic program flow is somewhat intuitive. You can start <em>without</em> the loop and add it in later as you introduce the concepts. This simple exercise is straightforward enough to teach the underlying concepts of how programming works in a somewhat entertaining, interactive application. </p>

CC BY-SA 3.0
2017-06-02T15:48:41.023Z
This is potentially #1, #2, #3, #4...
Sean Houlihane
CC BY-SA 3.0
2017-06-02T15:39:05.413Z
2017-06-16T20:49:18.653Z
2017-06-16T20:49:18.653Z
Robert Cartaino
<p>I did a (rather unscientific) study of a few popular tutorials for Python to see what they did after "Hello, world":</p>

<ul>
<li><p><a href="https://learnpythonthehardway.org/book/ex3.html" rel="noreferrer">Learn Python the Hard Way</a> introduces expressions (<code>25 + 30</code>, <code>5 + 7 &gt; 3 + 1</code>), and implicitly hints at types (although never mentions them by name in the chapter after "Hello, world").</p></li>
<li><p><a href="https://www.codecademy.com/courses/introduction-to-python-6WeG3/0/1" rel="noreferrer">Codecademy</a> introduces variables (assignment), then types, then reassigning variables.</p></li>
<li><p><a href="https://automatetheboringstuff.com/chapter1/" rel="noreferrer">Automate the Boring Stuff with Python</a> introduces expressions and types.</p></li>
<li><p><a href="https://developers.google.com/edu/python/introduction" rel="noreferrer">Google's Python introduction</a> introduces assignment, expressions, and very quickly moves on to functions. The pace of their tutorial seems <em>a lot</em> faster than the others I checked.</p></li>
</ul>

<p>So, purely from what other tutorials and resources do, it seems that expressions are the most important next step. Notably, none of the resources I tested introduce <code>input()</code> in the next step—clearly, it's more important to learn about variables and how to store values from functions first. </p>

<p>If these resources are to be trusted, the best second program would look a little like this:</p>

<pre><code>print('5 + 2 is', 5 + 2)
print('5 is less than 4?', 5 &lt; 4)
eight = 2 * 4
print("2 * 4 is eight?", eight == 8) 
</code></pre>

<p>Note that in this example, you subtly introduce the fact that comparing values is done with <code>==</code>, not <code>=</code>, and there's a link to <code>bool</code> values, <code>int</code> types, etc. Whether you explicitly mention them at first is up to you—some resources do recommend it, and some don't.</p>

CC BY-SA 4.0
2022-01-08T14:57:24.423Z
Yeah, when a student asked how X can equal X plus one I was a bit started. I mean, we get a year older each year, right? How else would it happen?
Scott Rowe
CC BY-SA 3.0
2017-06-02T11:31:13.687Z
2017-06-02T11:31:13.687Z
Aurora0001
<p>You've just demoed your first bit of code in whatever language you're teaching. The requisite "hello, world" has been said. The program has been compiled (or interpreted) and run. Now what?</p>

<p>There has to be a program that follows "hello, world" that builds upon the basics of printing one line on the screen.</p>

<p><strong>What is the logical next step in an introduction to a new language and possibly to programming as a discipline in general? We all know program #0; what's program #1 and why?</strong></p>

<p>Note: I know this is subjective, but I'm hoping it leans the good way. I'm trying to ascertain the scaffolding at an introductory level. Once the cliched example is complete (not that it doesn't have a lot to teach in and of itself), what makes sense as the next curricular step? I think the need for justification based on experience, expertise, and facts helps it from being too broad, but I'm happy to revise if necessary.</p>

CC BY-SA 4.0
2019-03-31T19:51:02.220Z
FYI: The traditional meaning of "hello world," has nothing to do with learning a new language (or a first language). It always was about learning a new _toolchain_. It was not a program that you wrote for yourself; It was a program that somebody gave to you. As in, "Here, when you can get this known-good source code to compile and run, then you will be ready to compile and run something of your own."
Solomon Slow
CC BY-SA 4.0
2019-03-31T20:02:42.117Z
P.S., I am not an educator, I'm a software developer. Been working almost forty years, and still go through the "Hello World" experience--proving that I can install, configure, and use the build tools for a new project--on a pretty regular basis.
Solomon Slow
CC BY-SA 4.0
2021-11-09T09:13:11.560Z
Same goes for hardware. But we do blinking LEDs instead of Hello World.
Max
CC BY-SA 4.0
2022-01-07T22:13:21.077Z
A program that says: "*Buckle your seatbelt Dorothy, 'cause Kansas is going bye bye*"
Scott Rowe
CC BY-SA 4.0
2022-01-08T23:41:05.607Z
If you're really going that far back, why are you advocating "hello, world" with no capitals? When you think the need for justification based on experience, expertise and facts "helps it from being too broad" what does that mean? When you're happy to revise, why not run two or three suggestions up the SE flagpole?
Robbie Goodwin
<curriculum-design><introductory-lesson>
What program follows "hello, world"?
# What program follows "hello, world"?

(Asked by: username_0 on 2017-06-02)

You've just demoed your first bit of code in whatever language you're teaching. The requisite "hello, world" has been said. The program has been compiled (or interpreted) and run. Now what?

There has to be a program that follows "hello, world" that builds upon the basics of printing one line on the screen.

**What is the logical next step in an introduction to a new language and possibly to programming as a discipline in general? We all know program #0; what's program #1 and why?**

Note: I know this is subjective, but I'm hoping it leans the good way. I'm trying to ascertain the scaffolding at an introductory level. Once the cliched example is complete (not that it doesn't have a lot to teach in and of itself), what makes sense as the next curricular step? I think the need for justification based on experience, expertise, and facts helps it from being too broad, but I'm happy to revise if necessary.

**Tags:** curriculum-design, introductory-lesson

> **Comments:**
> **username_1**: FYI: The traditional meaning of "hello world," has nothing to do with learning a new language (or a first language). It always was about learning a new _toolchain_. It was not a program that you wrote for yourself; It was a program that somebody gave to you. As in, "Here, when you can get this known-good source code to compile and run, then you will be ready to compile and run something of your own."  
> **username_1**: P.S., I am not an educator, I'm a software developer. Been working almost forty years, and still go through the "Hello World" experience--proving that I can install, configure, and use the build tools for a new project--on a pretty regular basis.  
> **username_2**: Same goes for hardware. But we do blinking LEDs instead of Hello World.  
> **username_3**: A program that says: "*Buckle your seatbelt Dorothy, 'cause Kansas is going bye bye*"  
> **username_4**: If you're really going that far back, why are you advocating "hello, world" with no capitals? When you think the need for justification based on experience, expertise and facts "helps it from being too broad" what does that mean? When you're happy to revise, why not run two or three suggestions up the SE flagpole?  

---

## 17 answers

### Answer by username_22 on 2017-06-02. Score: 23

When I was teaching and mentoring first-time students, what got them **really excited for the first time** was seeing their name in lights. Write a program that allows a student to enter their name, then print it on the screen 10 times (or 10,000).

* It introduces the concept of **variables and variable types**
* It shows how computers interact with the outside word by **accepting input** from the students
* It introduces **basic looping and conditional statements** in a really simple example
* It shows how **math and computation** works in a computer without simply spitting out basic algebra.

The best part is the students don't have to understand 100% of the program to start picking out the individual parts. The basic program flow is somewhat intuitive. You can start *without* the loop and add it in later as you introduce the concepts. This simple exercise is straightforward enough to teach the underlying concepts of how programming works in a somewhat entertaining, interactive application.

> **Comments:**
> **username_23**: This is potentially #1, #2, #3, #4...  

---

### Answer by username_24 on 2017-06-02. Score: 13

I did a (rather unscientific) study of a few popular tutorials for Python to see what they did after "Hello, world":

Learn Python the Hard Way introduces expressions (25 + 30, 5 + 7 > 3 + 1), and implicitly hints at types (although never mentions them by name in the chapter after "Hello, world").
Codecademy introduces variables (assignment), then types, then reassigning variables.
Automate the Boring Stuff with Python introduces expressions and types.
Google's Python introduction introduces assignment, expressions, and very quickly moves on to functions. The pace of their tutorial seems a lot faster than the others I checked.

So, purely from what other tutorials and resources do, it seems that expressions are the most important next step. Notably, none of the resources I tested introduce input() in the next step—clearly, it's more important to learn about variables and how to store values from functions first. 
If these resources are to be trusted, the best second program would look a little like this:
print('5 + 2 is', 5 + 2)
print('5 is less than 4?', 5 < 4)
eight = 2 * 4
print("2 * 4 is eight?", eight == 8) 

Note that in this example, you subtly introduce the fact that comparing values is done with ==, not =, and there's a link to bool values, int types, etc. Whether you explicitly mention them at first is up to you—some resources do recommend it, and some don't.

> **Comments:**
> **username_3**: Yeah, when a student asked how X can equal X plus one I was a bit started. I mean, we get a year older each year, right? How else would it happen?  

---

### Answer by username_6 on 2017-06-15. Score: 9

After "Hello World" it becomes "Hello \$name" where \$name is provided by user. After basic I/O and "it compiles and runs", then it is time for loops and logic. I typically like a variation on fizzbuzz:

> Print the numbers 1 through 100, if the number is evenly divisible by 3 print "fizz" next to the number, if evenly divisible by 5 print "buzz" next to the number, if evenly divisible by both 3 and 5 then print "wahoo!" next to the number.


---

### Answer by username_5 on 2017-06-11. Score: 7

I was taught that there were three main aspects of programming:

input-output,
computation, and
logic/control

"Hello world" is an "input-output" function, specifically a "print" command. The next thing I would teach is a simple computation, even something like 1+1=2.
For example:
X=1
Y=X+X
Print Y

> **Comments:**
> **username_6**: TBH logic/control should come first - but in order to see it happen and make sure it works, you need the I/O too (well, at least the O)  

---

### Answer by username_7 on 2017-06-22. Score: 7

I've always used Hello name" as part of Hello World. It's easy enough for most students and makes the program more fun. After Hello World I use a conversion program. For example Fahrenheit to Celsius. That makes a lot of sense in the US but might not in other countries. But there are many conversions that make local sense in other parts of the world. Pounds Sterling to Euros perhaps. Students often like money problems.

Conversion programs involve both input and output but add the introduction of assignment statements and calculations. More involved calculations allow for a review of the order of operations (one reason I use Fahrenheit to Celsius). Students get interesting results if they don't set up the formula correctly.

Conversion programs also let one introduce testing early in the game. Sure the program compiled, ran, and gave you an answer but how to you know it is the right answer?


---

### Answer by username_8 on 2017-06-30. Score: 6

There's absolutely no reason your first program needs to be `"hello world"` in the first place.

You can start with values of various kinds, and show how to combine them to create more interesting values. For instance, in *How to Design Programs*, we start out with numbers, strings, *and* images.

Pretty quickly students can start to create interesting pictures: e.g., flags of various countries, or a scene (imagine a beach with a tree and a sun). Now they can start to change the size of that flag or parts of that scene (e.g., the sun is at different positions).

Next they can make a function that given a parameter, produces the flag or scene at that time (by using the parameter to calculate the position of the sun). Now they supply this to a function called `animate` and they have their first animation. From there they can go on to much more sophisticated animations.

In short, we think a rocket launching off a pad — a good metaphor for their education — is a pretty nice follow-up, and not that hard to do. The book's prologue (<http://www.ccs.neu.edu/home/matthias/HtDP2e/part_prologue.html>) shows this progression.


---

### Answer by username_8 on 2017-06-03. Score: 5

You program with images, create the flags of several countries, then lay them over backgrounds, then animate them, and build up to a game. You can do all that in the first week or so of your course if you have the right curriculum. See, for instance, the prologue of [*How to Design Programs*](http://www.ccs.neu.edu/home/matthias/HtDP2e/part_prologue.html) (second edition).

> **Comments:**
> **username_0**: +1 for DrRacket which I love as an environment and would love to teach with some day.  
> **username_8**: If you're at the middle-/high-school levels, take a look at the [Bootstrap](http://www.bootstrapworld.org/) family of curricula. There's something in there for everyone, and cut from the same cloth.  
> **username_9**: This does not seem like a program that would come right after "Hello World", it seems more complex than that.  

---

### Answer by username_10 on 2017-06-29. Score: 4

I think that a reasonable next step is showing them variables with an I/O basis. Things like:

* using "Hello, world!" or something similar as a string and printing it
* using integers and showing students the different operators for the language (add/subtract/multiply/divide/modulus division/integer division)


---

### Answer by username_11 on 2017-08-23. Score: 4

## Consider also going the other way.

We often think of teaching from small to big. However it is often possible and beneficial to go from big to small. Bertrand Meyer does this in his course “Touch of Class”.

Provide the students with a working program, have them read the program, make some predictions on what it does, then run it, determine what some of the key grammar/vocabulary does, make predictions on what changes will do, then make changes and re-run.

> **Comments:**
> **username_12**: I think this is an important answer.  
> **username_13**: But there are quite some preconditions before this can happen.  

---

### Answer by username_14 on 2017-06-02. Score: 4

The next step is to introduce the type system. Students need to know what kinds of data are "understood" by a language. The "Hello World" program gets the ball rolling because you can ask, "How is text stored? Are there other types of data that can be stored as well?"


---

### Answer by username_15 on 2017-08-23. Score: 4

I found 'FizzBuzz' really helpful as the next exercise, it has conditions, loops and it also allows you to explain some coding practices, especially DRY (Don't Repeat Yourself).

"Write a short program that will simulate playing FizzBuzz.
The rules are simple:

* Count from 1 to 100 and print the numbers on screen
* If the number is divisible by three, print Fizz instead of the number
* If the number is divisible by five, print Buzz
* If the number is divisible by both three and five, print FizzBuzz

Write as few lines of code as possible."

This is also an exercise that was used a lot on job interviews to determine if someone could actually code and apply good practices.

And for an in-depth explanation on what constitutes a good result:
[Tom Scott: FizzBuzz](https://www.youtube.com/watch?v=QPZ0pIK_wsc)

> **Comments:**
> **username_12**: Nice! And welcome to [cseducators.se]. I hope we hear more from you!  

---

### Answer by username_17 on 2017-06-30. Score: 4

I very much like "The Devil and Daniel Webster", as introduced to me by Devika Subramanian. It connects programming to mathematics, and introduces lists, loops, and if conditions in a fairly simple wait, with an interesting story.

The lecture notes I've found for them are below, but the problem is:

> The devil made a proposition to Daniel Webster. The devil proposed paying Daniel for services in the following way:"On the first day, I will pay you \$1,000 early in the morning. At the end of the day, you must pay me a commission of $100. At the end of the day, we will both determine your next day's salary and my commission. I will double what you have earned at the end of the day, but you must double the amount that you pay me. Will you work for me for a month?""

<https://sites.google.com/site/publiccomp140site/week-1/the-devil-and-daniel-webster-lecture-notes>

> **Comments:**
> **username_12**: I don't entirely understand the problem. Do we have some way of determining what D.W. will earn? I'm any case, welcome to [cseducators.se]!  
> **username_17**: It's just the payout minus the commission: so 900 for the first day.  
> **username_12**: So, on the second day, he would earn \$1,800, but have to pay \$200?  
> **username_17**: Exactly. Have them turn it into a pair of formulas for each day with subscripted variables.  Then we start writing code, and see that we'd end up with 60-odd variables. Introduce lists as a way of having variables with subscripts.   Then build up lists manually a few times, and introduce them to for loops.   Then at the end you can use an if, outside the loop, to check the final values.   Lists, for loops, and if statements. For my non-majors class it takes three 70-minute classes to get through, but it presents a coherent (if fanciful) problem to motivate them.  

---

### Answer by username_16 on 2017-06-07. Score: 3

I agree with the answer proposing Hello name, and the answer that proposes students inputting their name and then repeating it x times. Then a conditional can be introduced that does or does not print their name depending on some boolean expression or similar. At this point, we would have introduced: types, input (and output), repetition, conditionals, and possibly some mathematics.


---

### Answer by username_18 on 2017-08-23. Score: 2

You might find some more ideas here:

* [Order to Teach Topics in an Intro Programming Class](https://cseducators.stackexchange.com/questions/2793/order-to-teach-topics-in-an-intro-programming-class/2798#2798)
* [The order of subjects in beginner's curriculum](https://cseducators.stackexchange.com/questions/2903/the-order-of-subjects-in-beginners-curriculum/2924#2924)

My approach is designed for [Processing](http://processing.org), but hopefully it generalizes to other languages.

Hello World is really a lesson in **how to call functions**. After they understand the basics, I'd show them how to lookup other functions in either the language reference or in a beginner-friendly list that you give them. In Processing, I'd have them draw a circle or a rectangle, or an entire scene using basic function calls. If your hello world is a console application, then maybe have them display a popup box, or display a message in a window. The specifics of this depend on the language you're using, but the idea is to get them looking stuff up in a reference and playing around with their own code.

From there I'd go to **using variables.** This is different than creating variables. Instead of having students create variables, have them look up whatever predefined variables your language offers. Processing has `width` and `height` variables, so I'd have them make their scene scale to the size of the window. But you would use whatever variables your language exposes. Again, have them look stuff up in the reference or in a list you provide them.

From there I'd have them create their own variables and their own functions, which I've explained in more detail in the above questions. But if you're just looking for a follow-up to Hello World, I'd use the above approach of revealing more of the reference and asking them to do their own projects based on what they just learned.


---

### Answer by username_19 on 2021-11-06. Score: 1

Existing answers have great suggestions...
There are many wonderful answers here, and I agree that, in general, "hello ${name}" to introduce dynamic input/output and string concatenation (a natural lead-in to if/else and something like a small quiz app), currency/temperature convertors to introduce mathematical operations and types are great second tasks. A temperature converter with hardcoded values is a refactor away from collecting input, introducing functions, conditions (prompt for Fahrenheit to Celsius or vice-versa) and loops (prompt for multiple temperature conversions).
I also like the idea of prematurely showing students code from a larger project they aren't expected to understand, with the idea of making a few small modifications and exposing them to the look and feel of the sort of applications they'll soon be creating. There's a risk of intimidation, so care would need to be taken, and eventually you'll have to pull back to a "next hello world"-sized step anyway.
... but what about audience, context and goals?
However, these answers seem to assume an audience of entry-level programming students. As pointed out in the comments, plenty of advanced tutorials and courses might begin with a "hello world"-style task.
For example, in back end web development, any first-time Ruby on Rails tutorial will begin with getting the "Congratulations! You're on Rails!" screen up on localhost. For machine learning libraries, a classifier using the iris dataset is a canonical first order of business.
The point here is that audience, language, framework and context matters in choosing a second task, and "hello world" isn't exclusive to beginning programmers or console-based contexts.
With that in mind, a few answers recommend FizzBuzz after "hello world". Initially, this struck me as rushing in too many fresh concepts that can take time for beginners to grasp: loops, booleans, branching and string manipulation. But if the audience has prior programming experience, FizzBuzz might be a reasonable difficulty for them. And if not, you can always build up, adding the conditions slowly, then the loop.
I recently began learning Haskell from "hello world", and found that I wrote a dozen or so smaller programs before I was able to write a FizzBuzz that accepted input, to cite an example of the language factor.
Working backward from the goals of the course, the next step.
I'll continue onward assuming beginners, though, since follow-ups to "hello world"s for experienced developers looking to learn the latest framework would be a case-by-case basis.
In any situation, working backward from the goals of the course, the next step after "hello world" might become obvious.

A "10 PRINT" approach
Answers so far mostly offer a command-line style, general-purpose task that would work in basically any language. But many languages (particularly educational ones like Racket, Scratch and BASIC) offer interesting features that make it easy to do relatively engaging and powerful things without much effort. One suggestion is to try to find and exploit these in whatever environment you're working in. In particular, I find that graphical programs, and particularly animations, are a great way to engage students, even if only ASCII.
A classic example is 10 PRINT, a simple BASIC program that produces a cool animation
10 PRINT CHR$(205.5+RND(1)); : GOTO 10

10 PRINT is not always as easy to achieve in other languages and environments (it exploits aesthetics of the environment's screen, native text wrapping, an easy-to-write infinite loop, and an easy-to-call random number generator), but there's often some other "hack" that happens to create a disproportionately cool effect of some sort in your language.
For most scripting languages, it's pretty easy to provide boilerplate to do animations. In Python:
from time import sleep

while True:
    print("hello world!")
    sleep(1)

Working with this basic framework, you can introduce numbers, math operations and string manipulation to add dynamism to the animation (and later on, explain the loop and import in more detail; it's good early exposure):
from time import sleep

i = 0
while True:
    print(i % 10 * "@")
    i += 1
    sleep(0.1)

The * operator in Ruby and Python and x in Perl shows another easy trick for one-upping "hello world". String repeat functions, when available, are fantastic: "Na" * 10 + " Batman!". This works great with the print your name suggestion elsewhere in the thread.
We can try 10 PRINT in Python (although the results won't be too impressive without the C64 monitor; consider adjusting terminal color and typeface prior to the session):
from time import sleep
from random import choice

while True:
    print(choice(r"\/"), flush=True, end="")
    sleep(0.01)

or print the "\b" character to make a little animation in-place:
from itertools import cycle
from time import sleep

for c in cycle("what's up?"):
    print(c, flush=True, end="")
    sleep(0.5)
    print("\b", end="")

or:
for s in cycle(("hello", "world")):
    print(s, flush=True, end="")
    sleep(1)
    print("\b" * len(s), end="")

Even if students won't understand the code out of the box, they can play around with the string contents and speed, building intuition for what the shape of the code looks like and how it can create something dynamic and interesting with just a few lines.
Al Sweigart has a repository of scroll art scripts for further inspiration, although most are more than a step after "hello world".
Other ideas
Many languages have turtle or another minimal graphics library that lets you draw a circle with 2-3 lines of code and might be a great next step after "hello world". This is a great choice for students coming from a Scratch background who may be prone to frustration at the relative difficulty of doing anything "fun" with text-based languages.
In HTML, I find that a  tag can open a world of creative options for ASCII art without having to learn coding concepts immediately, similar to stacking a bunch of print statements or a multiline string to create an ASCII banner.
The nonstandard  tags, although technically horrible, helped turn my generation on to web development, and are a great way to jazz up "hello world" (when supported). Sure, HTML is probably not relevant for most curricula here, but concepts like this can often inspire ideas for other languages.
CSS offers powerful animation and transition techniques with just a line or two of code. For example, providing something like


can get students interacting with their app and provides a foundation for adding CSS properties, creating new elements and designs.
For front-end JS, students can easily use the browser's development tools to manipulate content on Wikipedia or another popular website. For example, without writing code, they can change text to humorous effect while being exposed to the syntax and structure of HTML.
If you don't mind sharing code students might not understand at first but will surely get a kick out of, you can try something like:
document.querySelectorAll("*").forEach(e => {
  e.style.background = "#" + Math.random().toString(16).slice(-6);
});

which sets all element backgrounds to random colors on a page, creating a glitchy art effect and hopefully giving students an idea of what's possible in the spirit of 10 PRINT. Snippets like these can open up conversations about creative coding, computer art and history (even if those aren't the focus of the course).
It's OK to make a mess
Following the  principle, in most cases, it should be fine at this stage to let students make a mess and have fun, duplicate code everywhere, then enforce better software engineering principles later. Ugly and outside-the-box is encouraged. For web programming, grabbing snippets from w3schools is OK.
For example, I've seen students push a few of their laptops together in a row and sync up the timing of their animations to make it look like text is scrolling between monitors! Encouraging creative, emergent collaboration among students and the tools in the environment enables students to create interesting experiences even with small amounts of code, as 10 PRINT does by exploiting aesthetic qualities of typeface and monitor.


---

### Answer by username_21 on 2022-01-07. Score: 1

You say you're looking for a program

> that builds upon the basics of printing one line on the screen.

I don't look at "hello world" as a basis to build upon. It's more of a sanity check: can the student use an editor, compile, run a program. The next program does not need to build on it per se.

So for my students the next step is the "[Collatz conjecture](https://en.wikipedia.org/wiki/Collatz_conjecture)". For that

1. They need expressions: `3*n+1`, `n/2`
2. Conditionals: `if (n%2==0) n=n/2; else n=3\*n+1;
3. Loop: `while (n!=1) /\* the above \*/
4. Nested loops: find the starting point (say under 1000) with maximum length.

And those do all built on each other. Prime number testing/finding is also a good one.


---

### Answer by username_20 on 2017-06-06. Score: -2

Historically, `Hello,` , but I think I'm going to go with something like hangman, snake, guess the number... I'm leaning more and more to "hacking" existing programs rather than learning bit by bit.


---

