While a program is running the CPU needs to retrieve data from memory (fetch). This data is then decoded. That is, checked to see if it is a value or an instruction, it is then executed.
https://www.youtube.com/watch?v=KD8a2VkZeyg
While a program is running the CPU needs to retrieve data from memory (fetch). This data is then decoded. That is, checked to see if it is a value or an instruction, it is then executed.
https://www.youtube.com/watch?v=KD8a2VkZeyg
So I was reading the BBC news website which has an article on GCHQ’s Christmas card.
This led me to wonder what is was as I hadn’t seen one before, it turns out it is a nonogram or picross. Then it suddenly hit me, this is a form of run length encoding, that we will be covering later in the course. It’s just that in this case the encoding is only for black squares. Anyway I just wanted to share it now while it was topical.
| Theme: | Arrays and Records |
|---|---|
| Subjects: | Higher Computing Science |
| Audience: | Student |
| When: | Wednesday, 9 December 2015 7:30 PM |
| Presented by: | Ian King, SCHOLAR Online Tutor for Computing Science |
| Session link: | http://heriot-watt.adobeconnect.com/scholarhomework (Enter as a Guest) |
A boolean variable is used to store True or False values. This can be very useful in programs, as you can use it in the program logic.
In the example below the user has to choose to exit the program, this sets the quitProg boolean variable to True which makes the result of the condition in line 3 False. Notice that True/False have capitals at the start of the value.
1 2 3 4 5 6 7 8 9 10 11 |
quitProg=False while not quitProg: #Program does stuff here choice=input('Do you want to quit (Y/N):') if choice in 'Yy': quitProg=True print('Exiting program') |
Input validation is used in both National 5 and at Higher. It consists of 3 parts.
The use of the while construct allows the program to repeatedly ask the user to enter valid data.
1 2 3 4 5 6 7 8 9 |
age=0 #Input Validation age=int(input('Please enter your age>')) while age<0 or age>120: # Check that age is between 0 and 120 print('Please check your age is between 0 and 120') age=int(input('Please enter your age>')) print('Welcome') |
This can also be used with strings, can you work out how to modify the code so that it would only take a ‘Yes’ ‘No’ answer?
| Theme: | Procedures, Functions and parameters |
|---|---|
| Subjects: | Higher Computing Science |
| Audience: | Student |
| When: | Wednesday, 18 November 2015 7:30 PM |
| Presented by: | Ian King, SCHOLAR Online Tutor for Computing Science |
| Session link: | http://heriot-watt.adobeconnect.com/scholarhomework (Enter as a Guest) |
This week we are going to create a database using Top Trumps as the information source.
What is your favourite?