Dahlia (and a little bit about Bash programming with kids) :: Daily and Fresh πŸ“· (231/366)

Hello!

This is a photo I am definitely not very content with. I took plenty of shots from different sides of the plant. But still struggled with everything from lighting to composition. I just couldn't seem to get it right. Everything failed.

I feel like giving up.

Changing the subject...

Parenting / Programming Bash

A few days ago I taught Miro some programming, using the Bash command shell. We wrote a number guessing game together. I told him what to write line by line in an editor, and told him what each line will do.

Here's my version of the program:

#!/bin/bash

# Satunnaislukupeli

satLuku=$((RANDOM%100+1))

echo -n "Arvaa luku (1-100): "

while read arvLuku 
do
# echo $satLuku

if [ $arvLuku -gt $satLuku ]
then
  echo "Liian suuri luku!"

elif [ $arvLuku -lt $satLuku ]
then
  echo "Liian pieni luku!"
else
  echo "Arvasit aivan oikein!!!"
  break
 
fi
done

Translations:

"Satunnaislukupeli" = "Random number game"
"Arvaa luku" = "Guess a number"
"Liian suuri/pieni" = "Too large/small"
"Arvasit oikein" = "You guessed correctly"

Miro made some (mainly linguistic) changes to his code though, but it worked too.
He was very impressed about what you can make the computer do.

Should I teach him the same in Python or Javascript? Maybe something else?

See ya!



Weeklies
Weekly and Fresh πŸ“Έ #32
Weekly and Fresh πŸ“Έ #31
Weekly and Fresh πŸ“Έ #30
Weekly and Fresh πŸ“Έ #29
Weekly and Fresh πŸ“Έ #28


Like my post? 🍻 Buy me a beer! 🍻

H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now
Logo
Center