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) |
National 5 – Boolean
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') |
N5 & Higher – Input Validation (Python)
Input validation is used in both National 5 and at Higher. It consists of 3 parts.
- Get the user to enter a value
- While the value is wrong
- Get the user to enter a value
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?
Higher – Scholar Homework Session
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) |
BGE – Top Trumps Database
BGE – Databases
This week we are going to create a database using Top Trumps as the information source.
What is your favourite?
Higher – Categories of High Level Languages
Computing Exit Pass
- Mini Languages are langues designed for one purpose Ex HTML is used for web design
- Domain Specific languages are also know as mini languages
- Procedural languages are the most common type
- Basic is a high level language designed to be easy to learn which became the popular language when computers became cheaper and popular in the 1970s
- Procedural languages are the most common type of programming languages
- Domain oriented languages focus on one task
- A scripting language is basically a mini Languages
- Prolog is a declarative logic language designed for artificial intelligence applications
- Learned the different types of coding applications.
Are these statements valid… Discuss.
Higher – Languages and Environments
JPG vs PNG vs GIF
Python on Raspberry Pi
For a bit of a change the class were programming in Python on a Raspberry Pi.
The program below was used to create a Gold Block in Minecraft.
1 2 3 4 5 6 7 8 |
from mcpi . minecraft import Minecraft import mcpi . block as block mc = Minecraft . create () pos = mc. player . getPos () x = pos.x y = pos.y z = pos.z mc. setBlock (x, y, z, block . GOLD_BLOCK .id) |
Created using http://hilite.me/ and http://www.geocraft.org.uk/