Around the Loops in Computer Science

Around+the+Loops+in+Computer+Science

Pixabay

There is no game that does not repeat any code in order for the game to run smoothly and having a fun concept. It is known that, while you don’t see the frames repeating themselves in front of your eyes, it is still happening in the coding.

Roger Mayo, computer science teacher, tells about his class being in the process of the programming involving in ‘loops.’ A loop is a sequence of instructions that is continually repeated until a certain condition is reached.

Mayo explained that it is hard to actually come up with an assignment that doesn’t include loops because they are so common. In the test that the students must take, it is between seventy to eighty percent on loops. That is why the students have seven assignments.

“Each one progressively getting more and more challenging,” stated Mayo.

Each assignment goes as follows:

  • A12.1 is going to be on loops, or Fun Loops, which contain two different parts, the magic squares and LCM or Least Common Multiple.
  • A12.2 is on pictures consisting of multiples which are the multiplication tables, pyramid, and starburst.
  • A12.3 is Loan Table, similar to taking out a loan and paying back with interest.
  • A12.4 is Grades which is eligibility.
  • A12.5 is Payments, which is like taking out a big loan and how much money would need to be paid over time (pay, then collect). To this, Mayo noted that he prefers “[the students] to actually put money into savings and then collect interest.”
  • A12.6 contains Parallel Lines, which is to draw horizontal lines and boxes in between them. And when one starts looking at it, the line looks wavy.
  • A12.7 ends with Game Land. It involves the students making the program work to where they could actually animate the dice before you roll them. The students are basically creating a game.

Mayo said, “[A12.7] turns out to be pretty incredible.”

Each loop does different things. Loops are going to make it to where the program reruns the students’ code more than once. Loops are used for different scenarios. When a game is running, sixty times per second (the frame rate), the loops are repeating over again, but changing the screen just barely. The loop changes the picture it’s going to show and possibly pauses it for a little while.

“Because a game wouldn’t be fun if you just rolled the dice once and moved once. You want the same thing to happen for the second player and then go back to the first player,” Mayo determined in regards to loops.

There are three different kinds of loops: The first is the ‘for’ loop, which happens a specific number of times, has a possibility that it won’t run any codes, and are arrays. The second is the ‘while’ loop; you don’t know how many times the program is going to run, but you want it to run until a certain condition is met. It also has a possibility of not running any code and is great for user input. The third is the ‘do while’ loop; this one is also unknown in terms of times the program is read, but it always runs a code and is great for menus.

Loops have a specific job in computer science. Even without seeing the coding, the loops are still there.