More results...

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

The FDE Cycle… In your own words

Before completing this task, you will need to revisit the main characteristics of the Von Neumann Processor Architecture.

You task is to write a description in your books or on the space provided below to describe, in your own words, how the FDE cycle works. Your description needs to include as many of the following key terms as possible.

Fetch Instruction Register
Decode Data Program Counter
Execute Memory location MAR
Primary Memory Control Unit MDR
RAM ALU Accumulator
Binary Clock speed GHz

The FDE Cycle… in your own words!

Describe, in your own words, how the FDE cycle works within the CPU. Use as many of the keywords provided above as possible.




Word Count: 0
unlock-access

Solution...

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

Anatomy of a computer program

Computer programs are a set of step-by-step instructions used to teach the computer how to complete a task.

Computer programs are written using a specific programming language. Nowadays, most programmers would write code using a high-level programming language such as Python, C, C#, Java, Ruby or Basic.

If we were to dissect a computer program, we would find the following elements:

  • Reserved Keywords & Built-in Functions
  • Identifiers (e.g. for variables and subroutines)
  • Values of different data types
  • Computing Operators
  • Punctuation signs
  • Comments/Annotations

Let’s investigate these elements further… Click on the sub sections below to find out more.

Reserved Keywords & Built-in Functions
The reserved keywords are defined by the language used to write your code. As opposed to a foreign language like French or Spanish, high level programming languages such as Python or Java only have a few dozen reserved keywords.

For instance, in Python 3.6 there are 33 reserved keywords and a few built-in functions such as print,input,str,int,float.

Here is a non-exhaustive selection of some of the most useful Python reserved keywords and built-in functions.

Reserved Keywords:

if elif else
while break continue
for in as
import from global
def return local
class del none
try except raise

Built-in Functions:

print input range
str int float
min max round
len chr ord
Identifiers (e.g. for variables and subroutines)
Identifiers are the name the programmers will choose when creating a variable, a constant, a function or a procedure. For instance, when storing the score of a game using the following line of code:

score = 0

score is the identifier of the variable that stores the score of the player.

Note that a programmer cannot used reserved keywords or built-in functions as identifiers in a program.

For instance in python you cannot have a variable called while as input is a reserved keyword of the language.

Note that, with Object-Oriented Programming languages, you will also use identifiers to give a name to your classes and objects.

Values of different data types
The values are the pieces of data used in a program. They can be hardcoded within the code or retrieved as input.

Each value as its own data type:

  • String values which contain a alphanumerical characters e.g. “James”, “Bond”, “007”
  • Integer values which contain whole numbers (positive or negative) such as 365 or -10
  • Float values (aka Real) which contain numbers which can have a decimal point such as: 3.14 or 9.81
  • Boolean values which are either True or False

Notice how, when using a string value in your code, you have to use “speechmarks”. This is because you do not want your computer to be confused between reserved keywords, identifiers and string values.

Computing Operators
There is a range of different operators that can be used in a computer program including:

  • The Assignment Operator =, used to assign a value to a variable or a constant e.g.
    score = 0
  • Arithmetic Operators +, , *, /, **, //, % used to perform arithmetic calculations
  • Comparison Operators <, >, <=,>=, ==, !=
  • Boolean Operators and, or, not
Punctuation signs
Each language has its own syntax and its own set of punctuation signs. In the English language the example of punctuation signs are the comma ,, the full stop., the question mark ?. And syntax in a language do matter as omitting or using the wrong punctuation sign it can alter the meaning of a message. For instance, would you go swimming in these waters, knowing that “crocodiles do not swim here”?

Programming languages have their own syntax too. Not using the correct syntax in your code will generate a syntax error. This means that your computer cannot interpret your code and hence will not run it.
In Python, the main punctuation signs are the brackets (, ), [, ], { and } the colon : and the comma ,.
Comments/Annotations
Finally, most programs will include some comments (aka annotations). These are optional and are only for the benefit of the programmers who will read and work on your code. Comments provide key explanations of what a section of code is doing. Comments will be completely ignored by the computer.

In Python, comments have to start with a # sign. e.g.

#This is a single-line comment

You can also create comments over multiple lines using a triple quote: “””. e.g.

""" 
    This is a multi-line comment.
    You can add much more information here.
    These are often used at the top of your code to specify:
         - the version number, 
         - the date the code was last updated
         - copyright information.
"""

Your Task

Your task is to identify all the different elements of the short program below, and drag them in the corresponding sections.
Anatomy of a Computer Program – Drag and DropOpen in New Window

The Von Neumann Processor Architecture

John Von Neumann (1903-1957) was a Hungarian-American mathematician, physicist and computer scientist and a founding figure in computer science, with significant contributions to computing hardware design.

The Von Neumann architecture refers to a processor architecture which has access to a program stored in primary memory as a set of instructions. A processor based on the Von Neumann architecture can execute these instructions sequentially using the Fetch Decode and Execute cycle (FDE Cycle).

Nowadays most general purpose computers are still relying on the key characteristics of this architecture. Within the Von Neumann architecture the processor consists of a control unit, an arithmetic logic unit (ALU) and some key registers used to store numerical values within the processor. These include a Program Counter (PC), an Accumulator, a Current Instruction Register (CIR), a Memory Data Register (MDR) and a Memory Address Register (MAR). These registers are used during the FDE cycle for the processor to fetch instructions and transfer data (between the processor and primary memory) and to execute these instructions.

The rate at which a processor can perform the FDE cycles to process instructions is called the clock speed. For instance, a processing unit with a 3.5GHz clock speed can process 3,500,000,000 instructions per second.

Recent computers have a high clock speed and more advanced processors may also have multiple cores (dual core, quad core etc.) which enable them to process several FDE cycles simultaneously. They may also contain cache within the CPU which can be used to store (and retrieve at a very fast rate) recently or frequently used instructions or data without the need to retrieve these from primary memory. A Central Processing Unit (CPU) with multiple cores, a certain amount of cache and a high clock speed will lead to an increase of the performance of the CPU.


Inside the CPU – Drag and DropOpen in New Window

Poem Decoding Challenge

To celebrate the start of the Winter, we have asked our Artificial Intelligence “AI-101” to generate a poem about the cold winter weather. The AI has generated the following poem which consists of a list of numbers! We believe the poem is in a compressed format. We found within the log of the AI a hash table (codebook) as appearing on the tablet below.

We believe this codebook is the key to uncompress the poem. (Click on the picture below to open full screen)

Challenge #1

Use the above codebook and printed poem to reveal the title and 8 verses of this poem.

Challenge #2

Implement a recursive algorithm to uncompress this poem using the given hash table by completing the code below.

unlock-access

Solution...

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

Playing Cards Sorting Algorithm

The aim of this online activity is to sort a set of 8 playing cards randomly picked from a deck of cards based on the following rules:

  • The cards need to be sorted in ascending order of their values. For the purpose of this task, an Ace will be the lowest value (1) whereas a King will be the highest value (13).
  • In order reveal a card you need to click on it to flip it. However you will only be able to reveal two cards at a time.
  • Should you decide to swap two cards, you will need to drag one of the card on top of the other card. Both cards will then swap position.
  • If you believe a card is in position, you can tick the checkbox underneath it.
  • If you believe all 8 cards are sorted, you can click on the “Check if cards are sorted” button. If they are in the correct order, from lowest to largest value, all 8 cards will be revealed.
  • At anytime, you can start this task again with a fresh set of cards by clicking the “New Cards” button.

Your aim is to find a method (algorithm) that works for you and enable you to sort all the cards with a minimum number of swaps.

Playing Cards Sorting ChallengeOpen in New Window

Sorting Algorithms

They are a range of different algorithms that can be used for a computer to sort a list of values. You can investigate some of the most widely used sorting algorithms using the following blog posts:

Logic Gates Circuits used in a Theme Park

In this set of challenges, you will design and test some logic gates circuits to control different automated systems used to control the following rides of a Theme park:

  • Ferris Wheel
  • Drop Tower
  • Roller Coaster
Ferris WheelDrop TowerRoller Coaster

Ferris Wheel

A Ferris Wheel automated control system controls whether the wheel should be spinning or should be stopped.

The automated system is based on the following inputs:

  • A main switch is controlled by the main operator to decide if the wheel is in operating (spinning) or not.
    • If the switch is on, the wheel is spinning
    • If the switch is off, the wheel is not spinning, allowing for passengers to load/unload a cabin.
  • Weight sensors are also used in each of the cabins of this Ferris wheel. A sensor is “on” if the cabin it’s on is overloaded (too heavy). If any of the sensors is on, the wheel is automatically stopped. For the purpose of this task, we will assume that our Ferris Wheel only contains 4 cabins. We will therefore only use 4 sensors. In reality, more sensors would be needed.

Use our logic gates circuit simulator to design and test a circuit for the Ferris Wheel automated control system. (Click on picture below)

Drop Tower

To join the queue to get on board the Drop Tower, the passengers must comply with some safety rules. A control panel is available to control a gate to let a passenger join the queue. The control panel has 3 switches as follows:

  • Switch A to indicate whether the passenger is 12 or over.
  • Switch B to indicate whether the passenger is at least 4-feet tall.
  • Switch C to indicate whether the passenger is accompanied by an adult.

For the gate to open to let the passenger join the queue for the ride, the rules are as follow:

  • The passenger must be at least 4-feet tall.
  • The passenger must either be 12 or over and if not, they must be accompanied by an adult.

Click on the picture below to design and test the logic gates circuit to control the gate, so that if a passenger is allowed to get on board the Drop Tower, the gate is “on”, but if not the gate is “off“.

Roller Coaster

An emergency stopping system controls whether a signal should be sent to the train of a roller coaster to stop it, in case of an emergency. The system is based on the following inputs:

  • A main switch is controlled by the main operator to start (switch is “on”) or stop (“off”) the roller coaster. There are however only three locations on the track where it is safe for the roller coaster to be stopped.
  • There are 3 sensors on the track, one on each of these 3 locations. The sensor is “on” if it detects the train at this given location. At least one of the three sensors must be on for the train to be stopped.
  • A safety guard sensor is also used to detect if any of the safety guards are not securely locked in. When all safety guards are locked in, the sensor is “on”.
    If any of the safety guards are unlocked, the sensor is “off”: In this case, the train should automatically be stopped provided that the train is at one of the three safe locations to be stopped.

Use our logic gates circuit simulator to design and test a circuit for the Roller Coaster Emergency Stopping System.

unlock-access

Solution...

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

Code Maintainability Q&A

Question 1[4 marks]



The two Python scripts above were created by an IT manager of a school and are performing exactly the same task: to generate a username based on the student’s firstname, lastname and year group. Compare both of these scripts and identify what was done to the code to make it easier to understand, maintain and re-use in future projects?




Question 2[2 marks]

The IT manager would like to make this program more robust by adding a validation check on the year group. The school only has students in year 7 to year 13. How could the IT manager change the code above to make sure the user can only enter a value between 7 and 13 for the year group?




Question 3[4 marks]

The IT manager would like to test his new validation check on the year group. Identify 4 pieces of test data that the IT manager should use to perform a normal/valid test, an invalid test, a boundary test and an erroneous test?

Normal/Valid Test Data:
Invalid Test Data:
Boundary Test Data:
Erroneous Test Data:



The Marauder’s Map Coding Challenges

Welcome to Hogwarts, school of witchcraft and wizardry! For this set of challenges, you will be helping the famous wizard, Harry Potter, to recover all of his magical possessions.

Effectively, it would seem that a malevolent wizard did cast a spell on Harry Potter’s belongings. As a consequence, twelve of Harry Potter’s favourite magical objects have been buried on the school premises, within or around Hogwarts Castle.

Harry found a note on his bed containing 12 encoded messages that look like some kind of magical algorithms. He believes that he could use Professor Dumbledore’s Marauder’s Map to help him locate his 12 magical objects. However, Harry needs your help to decode these algorithms. Will you be able to use the Marauder’s Map and decode the 12 algorithms to locate all of Harry Potter’s magical artefacts?

The Marauder’s Map Coding ChallengesOpen in New Window
The Marauder’s Map Coding ChallengesOpen in New Window

The Moroccan Spices Box Set Puzzle

In the heart of the medina of Marrakech, you will find one of the largest and most colourful souks in Morocco. In this souk, you will find merchants selling traditional clothing, multicoloured carpets, pottery, jewellery, antiques, lanterns, spices, etc. On the spice square, Halim, a merchant of Moroccan spices, would like to sell different box sets of jars containing various spices. Halim has a collection of 10 jars and would like to create three box sets of exactly 250g each.

Could you help Halim create these three box sets using the following 10 jars. Each set must contain exactly 250g of spices. (Drag and drop the following jars to create three groups)

View Solution
There are more than one solution to this puzzle. Here is one possible solution:

Python Challenge

To help Halim to create similar box sets in the future, we would like to create a Python algorithm that suggests a possible solution for any given set of jars.

We will use a list to store the collection of jars available. For instance, using the current set of 10 jars, our list would be as follows:
jars = [150,20,20,10,80,130,110,90,100,40]

The aim of this challenge is to use a backtracking / recursive algorithm to work out a possible solution for this puzzle by creating three lists of jars, using the values from the above jars list to create 3 box sets of exactly 250g each.

unlock-access

Solution...

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

HTML and CSS Quizzes

Do you know your HTML tags used to create a webpage? Do you know how to use CSS to customise the look and feel of all the elements of this page? See how many HTML tags and how many CSS properties you can list in under 5 minutes by completing the following two quizzes.

To learn more about HTML and CSS you can use the tutorials from w3schools:

Tagged with: ,