More results...

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
post
page
Python IDE Dashboard

Question Time – Relational Databases


– Online Database –
– SQL Activities –

Feeling confident with your computing knowledge of Relational Databases?

Spend a few minutes to answer or research the following questions:


?
What are tables used for in a relational database?


?
How do tables, records and fields relate to each other?


?
What are the main data types when storing data values?


?
What is the purpose of a primary key?


?
What is the purpose of a foreign key?


?
What are the three types of relationship in a database?


?
Using a school database can you give an example of each type of relationship?


?
Why is the customer name not a good field to use as a primary key?


?
Why is meant by an autoNumber or autoIncrement field?


?
When storing data about cars for a car dealer database, what field could be used as a primary key?


?
Why is it sometimes necessary to create a link table?


?
What is the difference between an entity and a table?


?
What does the acronym CRUD stands for?


?
What language is used to run queries in a database? What does it stand for?


?
What are the main keywords used in the SQL language to start a CRUD query?


?
In a database what is meant by redundant data?


?
What is the purpose of normalisation?


?
Can you describe the characteristics of a relational database in 1NF, 2NF, 3NF.


?
What is meant by “flat file”?


?
What is meant by atomic data?


?
What is meant by referential integrity?


?
In a client-server web application, where is the relational database stored?


?
What is meant by “SQL injection”?

Tagged with:

BBC micro:bit – Automated Car Park Display

car-park-signOur aim is to use the BBC micro:bit to create an automated Car Park Display to inform drivers of the number of empty spaces left in a car park.

Our system should:

  • Be initialised with the number of available spaces in the car park set to 20 and the car park will be empty when the program is started.
  • When the car park is empty the micro:bit should display a scrolling message saying “Car park is empty”
  • car-park-empty

  • To enter the car park, the driver has to press the A button of the micro:bit. The display should then changes to calculate and display the number of empty spaces left: e.g. Scrolling text : “15 spaces left”.
  • car-park-15-spaces-left

  • When a car leaves the car park, they will press the B button of the micro:bit. The display should then changes to refresh the number of empty spaces left.
  • If the car park is full, the micro:bit should display the scrolling text: “No entry – Car park is full”. Drivers should not be able to enter the car park. Instead, should the A button be pressed the display should say “No entry – Car park is full”.
  • car-park-no-entry

Use the microbit.org website to get started!

Solution

We will complete this project in 4 blocks of code.

First let’s initialise two variables:

  • maxCapacity to store the total number of spaces of the car park. (e.g. 20)
  • emptySpaces to store the total number of empty spaces of the car park. To start with we will assume the car par is empty so we can set emptySpaces to the same value as maxCapacity.

Then we will decrement the number of empty spaces by 1, everytime the A button is being pressed. (A car enters the car park), making sure that we only let cars in if the number of empty spaces is greater than 0. (There is at least on empty space).

Using a similar approach, we will increment the number of empty spaces by 1 everytime the B button is pressed (A car leaves the car park)

Finally, depending on the number of empty spaces in the car park, we will display the relevant message as scrolling text to inform users of the number of empty spaces in the car park.

unlock-access

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area
Tagged with:

Caesar Cipher

In cryptography, a Caesar cipher, also known as shift cipher, is one of the simplest and most widely known encryption techniques. It is a type of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. For example, with a left shift of 3, D would be replaced by A, E would become B, and so on. The method is named after Julius Caesar, who used it in his private correspondence.

The action of a Caesar cipher is to replace each plaintext letter with a different one a fixed number of places down the alphabet.

Caesar_cipher_left_shift_of_3

The cipher illustrated above uses a left shift of three, so that each occurrence of E in the plaintext becomes B in the ciphertext.

The transformation can be represented by aligning two alphabets; the cipher alphabet is the plain alphabet rotated left or right by some number of positions. For instance, here is a Caesar cipher using a left rotation of three places, equivalent to a right shift of 23 (the shift parameter is used as the key):

Plain:  ABCDEFGHIJKLMNOPQRSTUVWXYZ
Cipher: XYZABCDEFGHIJKLMNOPQRSTUVW

When encrypting, a person looks up each letter of the message in the “plain” line and writes down the corresponding letter in the “cipher” line.

Plaintext:  THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG
Ciphertext: QEB NRFZH YOLTK CLU GRJMP LSBO QEB IXWV ALD

Deciphering is done in reverse, with a right shift of 3.

The encryption can also be represented using modular arithmetic by first transforming the letters into numbers, according to the scheme, A = 0, B = 1,…, Z = 25.[2] Encryption of a letter x by a shift n can be described mathematically as,

caesar-cypher-encoding

Decryption is performed similarly,

caesar-cypher-decoding

The Caesar cipher is named after Julius Caesar, who used it, more than 2000 years ago, to protect messages of military significance.

julius-caesar

Vercingetorix throws down his arms at the feet of Julius Caesar. Painting by Lionel Royer – Musée CROZATIER du Puy-en-Velay – France, Public Domain.

Caesar Cipher Wheel


A cipher wheel is a tool used to help decipher a message encrypted using the Caesar cipher:

Encrypted Message


Use a Python program to decode the following secret message:

caesar-encode-message
N qtaj uwtlwfrrnsl zxnsl Udymts!
Key: right shift by 5 characters


unlock-access

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area
Tagged with: ,

Access Rights using Binary Masks

Imagine a building with 8 rooms.

Binary-Mask-Room-Layout

Each room is fitted with a card reader used to give access or not to different members of staff.
Each member of staff has a card giving them access to some of the rooms.
The card is used to store an access code:

Access-Card-XL-1

This card gives access to:

  • Room 3,
  • Room 5,
  • Room 8.

Hence the Access Code: 00101001

Task 1: Access Denied!


Complete the following table to show which rooms these cards will give access to:

Access Card Room Access
Binary-mask-access-card-1
Binary-mask-access-card-2
Binary-mask-access-card-3
Binary-mask-access-card-4

Task 2: Centralised Override! – AND Mask


The site manager can control access to all the rooms by disabling or enabling access to specific rooms. He can do so by setting an access code mask consisting of 8 bits.
For instance the access mask 00001111 would mean that only rooms 5,6,7,8 are accessible (by authorised card holders) while rooms 1,2,3 and 4 are completely locked.

The locking system at the door uses both the access code of the staff member’s card and the building access mask to decide if a staff member can unlock a room:

Access-Card-AND-Mask

This means that this member of staff can only access room 5 and room 8. This operation consists of applying an AND mask to determine the resulting room access code.

Considering the following Access Mask:

00110011

Perform the AND mask filter to work out which rooms these staff cards will give access to.

Access Card Room Access
Binary-mask-access-card-1
Binary-mask-access-card-2
Binary-mask-access-card-3
Binary-mask-access-card-4

Task 3: Multiple Cards Access! – OR Mask


On specific occasions, a staff member is allowed to borrow a card from one of their colleagues. This may give them access to additional rooms. Using an OR mask between two access cards code we can figure out all the rooms an employee with two cards can have access to.

Access-Card-OR-Mask

Use an OR mask with the following cards access code to determine which rooms these sets of two cards will give access to:

Access Card 1 Access Card 2 Room Access
Binary-mask-access-card-1 Binary-mask-access-card-2
Binary-mask-access-card-1 Binary-mask-access-card-4
Binary-mask-access-card-3 Binary-mask-access-card-2
Binary-mask-access-card-4 Binary-mask-access-card-2
Tagged with:

Responsive Website Layout

When designing a website, you have to consider the different sizes of screens of your internet users. These may access your website using a computer (desktop/laptop), a tablet, a smartphone, a smart TV…

A responsive website is a website where the layout adapts to the size of the screen.

On a large screen, the layout may include a header, a footer, several columns, left and right panels. A responsive layout can then adapt to smaller/narrower screens such as smartphones by adopting a linear layout (where all the sections mentioned above appear one after the other).

responsive-layout-website-design

Using CSS it is possible to apply different sizes and positions to different sections of the website based on the size of the screen.

If you have used one of the layout from “HTML – Website Layout” then you can add the extra CSS provided below to make your website responsive.

@media screen and (max-width: 1040px) {
	BODY {
		margin: 20px 20px 20px 20px;
	}
	
	.page, .pageHeader, .pageContent, .pageLeftPanel, .pageRightPanel, .pageFooter {
		width: 100%;
	}
	
	.pageContent, .pageLeftPanel, .pageRightPanel {
		min-height: auto;
	}

	IMG {
		max-width: 100%;
	}
}

A quick approach to test if your website is responsive is to resize your bowser window to the size of a smartphone and see how your website behaves.

Other aspects of a website can also adapt to the size of the screen. These includes pull-down navigation menus, font sizes, picture sizes, interactive elements such as tabs, accordion menus… However these can sometimes be trickier to implement.

Video Tutorial

Tagged with: ,

Using Google Fonts

google-fontsWhen formatting text on a webpage, you will more likely want to use different types of fonts. You may be tempted to use fonts that are installed on your own computers. However, you need to be careful as there is no guarantee that these fonts are also installed on the computers of the client computers/tablets/smartphones of users who will access your webpage.

To remedy this problem, you can limit your choice of fonts to “web-safe” fonts. These are a set of fonts which are installed on nearly every computer/tablet/smartphone. Check this page to access a list of web-safe fonts: http://www.w3schools.com/cssref/css_websafe_fonts.asp.

The list of web-safe fonts being very limited, you may then investigate using Google Fonts. These are fonts that are hosted on Google servers and that you can link from your webpages. Which means every time a user loads your page, their browser will also load the required fonts from Google servers. Though this may slow down the loading of your page, it will give you access to hundreds of fonts to choose from and is a very reliable approach to spice up the look and feel of your website.

Check the list of available Google Fonts: https://fonts.google.com/.

The following video clip explains how to use Google fonts on your own webpages.

Video Tutorial


Additional Video:
Google Fonts in less than 3 minutes: https://youtu.be/peR9V-f9OkI

HTML & CSS Code


You will need to add the following code in the <HEAD> section of your code:

<link href="http://fonts.googleapis.com/css?family=YOUR_CHOSEN_FONT" rel="stylesheet" type="text/css">

And then in HTML your code either use the

<FONT face="YOUR_CHOSEN_FONT">...</FONT>

Or in CSS:

BODY, H1, P  {
   font-family: 'YOUR_CHOSEN_FONT';
}
Tagged with: ,

Resistor in Series and Parallel

In this blog post we will create a Python program that will help us calculate the total resistance when two resistors are connected either in series or in parallel.

This program will be based on the following formulae:
resistors-formulae

Program Flowchart


resistors-flowchart

Create the Code


Your task consists of implementing the code described in the above flowchart using Python. Then you will have to test your code by completing the test plan below.

Test Plan


Once your code is done, complete the following tests to check that your code is working as it should:

Test # Input Values Expected Output Actual Output
#1 R1: 6 (Ohms)
R2: 6 (Ohms)
Series
12 Ohms
#2 R1: 6 (Ohms)
R2: 6 (Ohms)
Parallel
3 Ohms
#3 R1: 6 (Ohms)
R2: 12 (Ohms)
Series
18 Ohms
#4 R1: 6 (Ohms)
R2: 12 (Ohms)
Parallel
4 Ohms
#5 R1: 33000 (Ohms)
R2: 56000 (Ohms)
Series
89000 Ohms
#6 R1: 33000 (Ohms)
R2: 56000 (Ohms)
Parallel
20764 Ohms
unlock-access

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area
Tagged with: ,

CSS Snowman

Complete the following snowman using HTML and CSS code. You can edit this code in a new window using this button:

Add a Message


Add a “Merry Christmas” message above or below your snowman. And use CSS and google fonts to format this message.

<DIV id="message">Merry Christmas!</DIV>

Gradient Effect


Customise the background of your page using a gradient effect in CSS.

Snow Effect


Check this codepen to add a falling snow effect.

merrychristmas

unlock-access

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area
Tagged with: ,

Astronomy Challenge

constellation

What is a constellation?


In astronomy a constellation is a grouping of stars on the celestial sphere perceived as a figure or design. There are 88 recognized constellations and each of these have been named after characters from classical Greek and Roman mythology as well as various common animals and objects.

Python Challenge


In this challenge we are using Python Turtle to draw famous constellations on the screen.

Each constellation is saved as a list. Each value of the list represents a star. Each star is also a list with only 2 values, the x and y coordinates of the star (drawn on a 2D screen). So a constellation is stored as a list of lists!

For instance, for Cassiopeia:

cassiopeia = [[-90,70],[-50,-10],[0,0],[40,-50],[100,0]]

Using a for loop we can then read the content of the constellation, to plot each star on the screen, one at a time, based on its x and y coordinates.
constellations

x,y Coordinates?


The canvas we are drawing on (using Python Turtle) is 400 pixels wide by 400 pixels high.
Look at the canvas below to understand how (x,y) coordinates work:

Python Code


Check the following code:

Your Task


Complete the following code by adding one more constellation of your choice.

You will find the pattern of the most famous constellations on this website.

sagittarius

unlock-access

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area
Tagged with: , ,

Escape Flowcharts

In this challenge you will be asked to solve four mazes by designing their matching escape flowcharts. You can download and print this pdf booklet to draw your flowcharts.

Maze #1: The Staircase


The first maze has already been solved for you:maze-flowchart-2

The escape flowchart for this maze is already done for you:
maze-flowchart-1

Maze #2: The ladder


maze-flowchart-3
Design the flowchart to escape this maze.

Maze #3: The spiral


maze-flowchart-4
Design the flowchart to escape this maze.

Maze #4: The expanding staircase


maze-flowchart-5
Design the flowchart to escape this maze.

Tagged with: