“Programming Logic” is defined by Techopedia as “a fundamental construct that’s applied to computer science in a variety of comprehensive ways” and involves “logical operations on hard data that works according to logical principles and quantifiable results.”
For example, using a programme language like Java Script, you can control the actions of variables within a programme. A variable is anything with a name that has a value.
Screenshot example:
In a game of Yahtzee, we can control the variables (i.e. the numbers on a dice) to show a certain message when each number has a certain count. For example, if the all the variables (i.e. “onesCount” “twosCount” ect.) equalled 5, the heading will say “Yahtzee!”
You can then add an “else” tag if none of the rules apply, to say “Bad Luck”.
Screenshot example:
Translates to…..
“If” statements tell the programme which rules to follow. For example, if a “Yahtzee!” appears, you can say the following rule:
if(onesCount == 5 || twosCount == 5 || threesCount == 5 || foursCount == 5 || fivesCount == 5 || sixesCount == 5) {if(onesCount == 5 || twosCount == 5 || threesCount == 5 || foursCount == 5 || fivesCount == 5 || sixesCount == 5) { document.getElementById(“messageBox”).innerHTML = “Yahtzee!”; }
Additionally, in simpler programmes, such as Scratch, you can add repetition loops to, for example, keep a variable doing the same thing for a certain length of time.
Screenshot example:
The light orange control, “repeat” will make the variable repeatedly move 4 steps and change colour while moving.
Until next time!