Category: National 5

National 5 – SDD Predefined Functions

So today we were looking over predefined function. For the N5 course we have to be aware of RANDOM, ROUND, & LENGTH.

The RANDOM function picks an integer between two values.

import random
number=random.randint(1,20) # random(StartValue,EndValue)
print(number)

The ROUND function rounds a real number (floating point) to a fixed number of decimal points.

a=1.2 # 1
b=2.6 # 3
c=2.5 # 2
d=3.5 # 4
e=3.453444354

print(round(e,2)) # round(valueToRound,NoOfDecimalDigits)

The LENGTH function displays the number of characters in a String or the length of an Array.

name="Stratton was here"
numbers=[1,2,3,4,2,3,4,6,4,3,2,43]
print(len(name))
print(len(numbers))
print(numbers)

for index in range(len(numbers)):
    print(numbers[index])

for index in range(len(name)):
    print(name[index])

 

N5 – CSS locations

There are three places that CSS data can be stored for use with HTML files.

Inline

Inline CSS applies to one html element it is added as the value for a style attribute.

<h1 style='color:red;'>Page heading</h1>

Internal

Internal CSS is declared inside <style> which is located in the <head> area of the page. It applies to one page of html.

<head>
<head>
 <style>
   p {background-color:pink;}
 </style>
</head>

 

External

External CSS is stored inside a separate text file (.CSS) it applies to all webpages that link to it (applies to whole site). A link is required in the <head> of the HTML file this link includes the name of the CSS file

<head>
  <link rel="stylesheet" type="text/css"  href="style.css">
</head>

The CSS file has the selectors and properties stored in the same way as internal

#redBox { background-color:red;
              Color:black;}

N5 – CSS Selectors

CSS is used to change the look of the website but not the HTML content of the website.

At National 5 there are 3 CSS selectors. These are used to identify which parts of the web page are styled by CSS instructions.

  • Element selector – This is used to select all html elements of the given type.

P {color:red;}

P is the element selector

Color is the CSS property

Red is the CSS value

  • Class selector – this is used to target HTML elements of a given class.

.center {text-align:center;}

.center is the name of the class selector

Text-align is the CSS Property

Center is the CSS Value

  • ID Selector – this is used to target a unique HTML element on the page. NB Only one ID with the same name on a page.

#pageHeading {color:white;}

#pageHeading is the ID selector

Color is the CSS property

White is the CSS value

Problem Solving – Software Development

As you are solving each problem you should be doing the following in your jotter before hitting the computer

Heading – Name of program

Description of problem – pick out the key things the program must do and write it as a paragraph (rewrite the problem in your own words)

  • Analysis
    • Inputs – What the user must enter to the program
    • Processes – What the program does with the inputs to create the outputs
    • Outputs  – What the program display to the user
  • Design (one of the following)
    • Pseudocode – numbered steps that the program follows
    • Structure Diagram
    • Flow Chart

Pseudocode

Pseudocode is a design methodology that uses structured written language to show the design of the program.

Although there are no formal rules for Pseudocode, in Coltness we use the following rules.

  • Instructions should make sense
  • Instructions should use line numbers
  • Instructions can use mathematical symbols
  • Use indentation and white space where required
  • One line of Pseudocode = one line of Python code
  • Try to use only structures that exist in the language the program will be written in.

 

 

N5 – CS – Security Precautions

Describe the role of firewalls.

  • A firewall protects against suspicious access to a computer from a network. When an external computer tries to access a computer, the firewall decides if the external computers access should be granted or denied.

 

Describe the use made of encryption in electronic communications.

  • Encryption encodes the information so that if it is intercepted then they would not be able to make sense of it. It can only be understood by the sender and received.

N5 – CS – Computer Structure

Describe the purpose of the basic computer architecture components and how they are linked together:

Processor

  • Control Unit – controls the sequencing of fetching, decoding and executing instructions.
  • Arithmetic Logic Unit – performs all calculations and logical operations
  • Registers – temporary memory locations within the processor.

 

Memory locations with unique addresses

  • All memory locations within RAM is given a unique address so that the computer can read and write data to that location correctly.

Buses

  • Buses are used to move data around as binary inside the computer system
  • Address Bus – this transfers the memory location that is going to read from or written to.
  • Data Bus – this transfers the data between the processor and memory, and vice-versa.

 

Explain the need for interpreters and compilers to translate high-level program code to binary.

  • Computers can only understand binary and therefore all instructions must be translated into binary before they can be executed.
  • Interpreter – translates one program line into machine code and executes immediately. Machine code is not retained, so must be translated each time, the Interpreter must therefore be resident in memory.
    • Good for testing, errors are highlighted straight away.
  • Compiler – All lines are translate to machine code, this machine code version is then saved and can be executed. Machine code can be run again, and again without further translation.
    • Used for programs that are ready for release.

N5 – CS – Data Representation

Describe and exemplify the use of binary to represent positive integers.

Convert from binary to denary and vice-versa.

  • An integer is a whole number.
  • Binary is how a computer system stores data. Everything stored by a computer is stored using
  • A Binary Digit (bit) is either a 0 or a 1
  • 37 =
128 64 32 16 8 4 2 1
0 0 1 0 0 1 0 1
  • Add the column headers where there is a 1 to go from binary to decimal so the example above is 32+4+1=37

 

Describe floating point representation of positive real numbers using the terms mantissa and exponent.

  • Floating point representation is for storing a number with a decimal point.
  • The mantissa and exponent are stored as separate numbers within the computer’s memory. The computer recreates the number for calculations when it needs to.
  • For the number 0.10111 x 21011 Mantissa =10111 Exponent=1011

 

Describe extended ASCII code (8-bit) used to represent characters.

  • Each character is given an 8-bit ASCII Code, this is a binary number.
  • For example – V = 86 = 01010110

 

Describe the vector graphics method of graphic representation for common objects:

  • Vector graphics are made up of objects. Each objects is described by attributes – e.g. the instructions to draw the shape.
  • Rectangle – (height, width, x, y, fill colour, line colour)
  • Ellipse – (cx, cy, rx, ry, fill colour, line colour)
  • Line – (x1, y1, x2, y2, line colour)
  • Polygon any shape with 3 of more sides – (x1, y1, x2, y2, x3, y3, fill colour, line colour)

 

Describe the bit-mapped method of graphics representation.

  • Computers stores, in binary, each pixel. The greater the number of pixel the greater the resolution and file size of the image. Number of bits per pixel depends on the number of colours in the image – more colours, more bits.

 

N5 – CS – Environmental Impact

Describe the energy use of computer systems, the implications on the environment

  • It is estimated that two billion computer systems are in use in the world – these all use energy. As user we need to consider how to reduce unnecessary energy use.

 

and how these could be reduced through:

  • Settings on monitors – reduce brightness, activate efficiency mode, use energy efficient monitors.
  • Power down settings – power-down after a period of inactivity, control setting for single components.
  • Leaving computers on standby – power consumption is reduced but it still uses some power, machines should be shut down when not in use.