29/11/13 – Computer System Presentation

This lesson I prepared a presentation about the first unit in the GCSE Computing Course of Computer System and how they operate. I also learned more about how an operating system function in relation to the hardware of a computer.

Screen Shot 2013-11-30 at 18.22.59

http://prezi.com/xkkvsd4lpwwh/?utm_campaign=share&utm_medium=copy

 

20/11/13 – Test!

Today we had our first computing test ever! After the theory, there were 2 short programming task. The first was to create a function which took in a number as input, and told you whether it was odd or even. I did this by using the mod (remainder) function to see how what the remainder of dividing the input number by 2 was. If the reminder was 1, then it was an odd number as it was not divisible by 2, else it was an even number.

Screen Shot 2013-11-23 at 16.23.51

 

The second was slightly harder, and asked you to use a while loop to get 3 scores from a test and print the largest value. My initial method was to use ask for 1 input each time you went through the list, which then get appended to the list called marks. Each time you went through the loop you would add 1 to the count variable , so that when count would reach 3, the function will stop, as you have entered the 3 required values. Finally, I print the max number of the list, which should be the top mark.

Screen Shot 2013-11-23 at 16.25.50

Some would argue that using the max function involves no actual logic and defeats the point of the task. So I decided to have another go a the task, instead this time without using a max function, and still abiding by the task specification.

Screen Shot 2013-11-23 at 16.35.24

 

This time my function goes through the list and checks against the maxnum, to see if the input value is greater. If it is greater, the if changes the variable maxnum to the inputed number. Both function resulting in the same output.

Screen Shot 2013-11-23 at 16.37.10

13/11/13 – Factorials

Today in class we were to make a program which solves the factorials of a value. A factorials is shown as a ‘!’ on your calculator and is the mathematical function which multiplies all the number which come before the number that is the coefficient of the factorial sign inclusive.

‘4!’ ———-> 4*3*2*1 = 24

However what made this task interesting was how we had to figure out the recommended logic using a given flowchart. As shown below.

flow_chartSo my solution involved going through a while loop and and multiplying the answer (originally set to 1) by the number entered. You change the value of the answer variable each time by setting it to the answer of the number multiplied by the answer. Also, every time you go through the loop you subtract 1 from the entered number. So when the number entered is equal to 1, the factorial, which is saved under the variable answer is printed.

Screen Shot 2013-11-23 at 15.41.16

I later realised I could have simplified this function in some ways. By putting my input into a for loop I have basically limited the range to which the function can multiply by the answer. Also I have also saved time, as I haven’t had to define another variable to house my input function. Thereby shortening my code by 4 lines. Yet I still have an idea with which I could shorten my code to 2 lines.Screen Shot 2013-11-23 at 15.54.25