Monday, December 8, 2014

Activity 1.3.7 - For Loops

Hangman Code:

Click on the image to enlarge it.


Lottery Ticket Code:

Click on the image to enlarge it.


Conclusion:

1.       Sometimes code using an iterative loop can be written without a loop, simply repeating the iterated code over and over as separate lines in the program. Explain the disadvantages of developing a program this way.

This program would run slower, as there are more lines that the computer has to run through. It also clogs up the code and makes it more difficult for programmers to read. Iterative loops help keep the code concise.

2.      Name a large collection across which you might iterate.

If you were to update the grades of everyone in the high school, you would be dealing with a large amount of students - a lot of data. Using iterative loops would help to streamline the process.

3.      What is the relationship between iteration and the analysis of a large set of data?

An iteration is some set of tasks completed on a particular object, one at a time. Iterative loops can be used to analyze large sets of data, using a relatively small amount of code to iterate each bit of data.

No comments:

Post a Comment