Basic Logical Structures in Programming

Sanjana Shah, Girls Innovate! Teen Committee
ThinkImagineProgram (Session 2)

“A designer is someone who constructs while he thinks, someone for whom planning and making go together.” John Maeda

We started the second session of ThinkImagineProgram by answering questions related to ‘Four-in-a-Row’ game, which required more thinking and was a little more complicated than Tic-Tac-Toe. This game can be hard if one is against a strong opponent, but by being a good observant and applying strategies, the chances of winning the game improves. Gradually, we moved to the next activity on ‘Men’s World Cup Final’ that had 8 games with 16 teams. With this activity, we learned about permutations, followed by binary numbers and patterns. The binary number system is base-2. This means it has only two numbers: 0 and 1. Each digit is referred as a bit. I tried writing down binary numbers for the three slots and noticed a pattern, where all odd numbers were ending in 1 and even numbers in a zero.

All programming languages utilize constructs, mainly selection and repetition. A selection statement provides selection between alternatives, using if and else. A repetition construct uses loops, until some end condition is met. We went through some of the examples where these constructs could be used. A good example of a nested loop is a car’s odometer and an infinite loop is the Infinite Loop Drive in Cupertino, where Apple Headquarters is located. After looping, we talked about how computers store values in variables, and how we can use arrays to store multiple values. We then jumped to the concept of swapping and how we can swap the values of two variables using a temporary third variable.

This activity was followed by a group activity, which was based on sorting, where we were asked to divide ourselves into two groups. Being the leader of my group of around 15 girls, I made sure that each girl had a playing card from a shuffled deck and knew what we had to accomplish. The objective was simple – sort ourselves based on the card each girl received. Sorting was not that difficult for us, as we divided ourselves based on ordering of colors, then suits and then numbers.

ThinkImagineProgram also introduced the participants to various UI components and stressed the importance of a good User Interface (UI), allowing users to interact with programs in an intuitive way. We concluded the session by discussing about various UI components like Button, TextField, TextArea, Label, CheckBox, RadioButton and two layouts, GridLayout and BorderLayout. As Ben Shneiderman has mentioned, “A picture is worth a thousand words. An interface is worth a thousand pictures.” We did not get time to talk in detail about HTML, Web Pages, and Web Services, which will be discussed more in the upcoming session.

Click here to watch ThinkImagineProgram Video

Leave a Reply