Author: Mr Stratton

Computing teacher and a PT at Coltness High School.

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.

 

 

S3 – Python Turtle

This weeks task is to solve the maze. You are not allowed to touch the black lines.

You can use any Python Turtle commands you want including

  • goto(x,y)
  • right(deg)
  • left(deg)
  • forward(length)

Save the image as maze.png and use the boilerplate code below in Thonny to start the task.


# Solve the maze
# Mr Stratton
# 7/6/19

from turtle import *
# Help here https://docs.python.org/3/library/turtle.html
setup(1000,600) # set the window size to 480x360 pixels
bgcolor('yellow') # set BG to yellow
bgpic("maze.png") # BG pic only works with PNG and GIF
title("Mr. Stratton's Maze Tutorial") # Title of window
color("red") # Colour line
# shape("arrow") # Shape of the turtle (“arrow”, “turtle”, “circle”, “square”, “triangle”, “classic”)
turtlesize(3) # size of turtle (easier for some kids to see)
pensize(3) # Set the size of the pen

penup()
goto(-420,220)
pendown()
# vvvvvv Enter your code below here vvvvvv

After you have solved the maze answer these questions:

  1. How many programming steps did you take?
  2. Can you reduce the number of steps?

Save a new copy of the program and edit it to make it more efficient (fewer lines). The number of extra lines that my program needed is below.

Read more

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.

 

Higher Revision Resources

Thanks to Mr. M. Hay for collating these

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.

Free CyberFirst Adventurers – Booking Now

GCHQ Cyberfirst course – this is not a school course.

These short courses are designed to introduce 11-17 year olds to the world of cyber security.

CyberFirst Adventurers

A free 1 day non-residential course aimed at 11-14 year olds. The course consists of four themed modules offering interactive, hands on, self-guided, exploratory learning that reduces the amount of time spent in traditional instructor led presentations to the very minimum.

Check out all courses and locations at

  • https://www.ncsc.gov.uk/information/cyberfirst-courses

Higher – Count Occurrences Standard Algorithm

The count occurrences algorithm is very similar to the linear search v1. However, it includes an incrementing counter keep track of how many items it finds.

def countOcc(target,numbers):
    #Count the number of times target is found in numbers
    count=0
    for number in numbers:
        if number==target:
            count=count+1
    return count

You will notice that I have used a FOR EACH in this example as there is no requirement to track the position of the elements. This algorithm can also be used to count how many numbers are above or below a target value by simply changing the operator in the IF statment.