Category: Old National 5

National 5 – Computational Constructs (Revision)

Expressions to assign values to variables

Number=0

Expressions to return values using arithmetic operations (+ – * / ^ mod)

Average=total/5

Execution of lines of code in sequence demonstrating input – process- output

1. SEND “Enter First Number” TO DISPLAY

2. RECEIVE first_number FROM (INTEGER) KEYBOARD [input]

3. SEND “Enter Second Number” TO DISPLAY

4. RECEIVE second_number FROM (INTEGER) KEYBOARD [input]

5. SET total TO first_number + second_number [process]

6. SEND total TO DISPLAY [output]

Expressions to concatenate strings and arrays using the & operator

Bob Smith is an example of concatenation

 

firstName=”Bob”

secondName=”Smith”

print(firstName + secondName)

 

BobSmith

Use of selection constructs including simple and complex conditional statements and logical operators.

This is a simple statement as there is one conditions

1. IF pupil_mark >=50 THEN

2.    SEND pass message TO DISPLAY

3. ELSE

4. SEND fail message TO DISPLAY

5. END IF

 

This is a complex statement as there are two conditions

1. IF pupil_mark >=50 AND assessments_mark = 100 THEN

2.     SEND pass message TO DISPLAY

3. ELSE

4.      SEND fail message TO DISPLAY

5. END IF

Iteration and repetition using fixed and conditional loops

Fixed loop below as it will loop a fixed number of times depending on the users answer

number=int(input(“How many smart phones?”))

total=0.0

for phone in range(number):

                Name=input(“Please enter the name of the smart phone:”)

                cost=float(input(“Please enter the cost of the smart phone:”))

                total=total + cost

print(“Total cost = “,total)

 

Below is a Conditional Loop as it depends whether the user has any money left.

money=int(input(“Please enter your pocket money in £”))

while money>0:

    name=input(“Please enter the name of the CD you want to buy”)

    cost=float(input(“Please enter the cost of the CD”))

    money=money-cost

print(“You have ran out of pocket money”)

Pre-defined functions (with parameters) – round(22.34 ) will round numbers 22.34 becomes 22 or sqrt(4) will get the square root 2, or 9 will become 3.

National 5 & Higher Course Content

You have a paper copy of this in your folders but I thought you might want an electronic copy.

The document is divided into

  • Yellow (SDD)
  • Orange (SDD & ISDD)
  • Red (ISDD)

For the exam National 5 pupils could be asked question from National 4 & 5. Higher pupils can be asked about content from all three courses.

TIP: Take a highlighter and mark of areas as you study them, use traffic lights to mark areas you need to come back to.

Internet 101

Quite a few students have been asking for a better explanation of how the Internet works. This sequence of videos takes you through all areas and aspects of the Internet. If you have a Khanacademy account (you do S4) then you can even earn a badge for watching the videos.

It is well worth a watch for National 4,5 & higher and it will now be making up part of our future courses.

Array Handling

In Python array handling can be accomplished by using Python’s built in list comprehension. This means when we are working with arrays we need to change the way we use the for loop depending on whether we are interested in the value or the position of the value.

list

In the code above the first for loop is simply printing the value from the list. The second loop knows the position of each item and can therefore display that information as well.