I've done something a bit like this for "career days" for elementary school kids. I coded up a perl script that was basically something like this:

    #!/usr/bin/perl
    $score = $ARGV[0]

    if ($score > 90) {
        print "A";
    elsif ($score > 80) {
        print "B";
    elsif ($score > 70) {
        print "C";
    elsif ($score > 60) {
        print "D";
    } else {
        print "E";
    }
And I'd ask, "What do you think happens if you put in '85'? What about 10000? What about -30?" If the group I was talking to seemed pretty sharp on the uptake, I'd ask, "If you wanted to hack it so that people who got 95 got an E, and people who got 50 got an A instead, what would you do?"

The kids really seemed to enjoy that. Apparently they even told the teachers I was teaching them to hack programs -- a bit concerning for the teachers, but mission accomplished as far as I'm concerned.

Look I don’t want to criticise but I’ve got to say, this is the sort of thing that makes kids hate programming.

“Hey kids ready to do some super exciting math in a computer program?” Nah.

I had a computer teacher who managed to make me bored and disinterested with stuff like this, despite me being crazy crazy crazy interested in computers.

The best way to teach kids programming is via programmable graphics I.e visual games making systems. Not written code.

Music programming languages could also be fun. Bonus points if you can produce interesting music and interesting graphics at the same time.

When reading your comment I remembered the old LucasArts game called Loom. I wonder if that would be a proper jumping off point for a music language? Of course, my memory could just be bad.

I am probably too young for that :) but this [1] seems a nice list, perhaps there's something similar

[1]: https://github.com/toplap/awesome-livecoding