Saturday, February 9, 2013

4-10 February 2013


I missed a day in Computer Science/Programming this week due to circumstances outside my control, making this a one-day week.  Still, it was as productive as any other week- that is, I did the assignment.

The assignment had to do with some rather random tests on numbers- a test of divisibility by 3, a test of divisibility by 3 xor 5, and a test of whether the number is 60 (and, if not, whether it’s bigger than 0/50/100).  That is to say, it was a rather odd exercise designed to test our ability to use:

* If statements.  These are the simplest- if a Boolean variable is “true”, certain lines run.  If it’s false, one can use elifs and elses to further divide up the options.

* While loops.  While a certain Boolean variable is “true”, certain lines run over and over again until it becomes “false”.

* For loops.  These allow one to run certain lines that include a variable for given values of that variable.  That is, the lines run a given amount of times, each time with a different value of the basic variable.

Whichever one of these is used, it is vital to include a colon at the end of the line- for instance, “if n==1:”.

No comments:

Post a Comment