More results...

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

Computer Science – Cryptic Crossword #02

Here is our second cryptic crossword for computer scientists! You can access our first cryptic crossword on this page.

Before attempting to solve this challenge, you should familiarise yourself with the different types of clues that the crossword definitions can be based on. Effectively, the definitions given in a cryptic crossword, will almost never be a literal meaning of the answer you are looking for. Instead, they will be based on a wordplay. When looking at a definition, you will first need to try to locate the two main hints which are:

  1. An exact definition or synonym, in much the same way as a conventional crossword clue. This can appear either at the start or at the end of the definition.
  2. Some sort of wordplay. There are many different types of wordplay that can be used. Sometimes an indicator term (a specific expression or word) will lead you to the type of wordplay that is being used.

Let’s investigate some of the most common types of cryptic crossword definitions:

Double DefinitionAnagramsAcrosticHidden WordsReversalHomophonesCharadesDeletionCrypticComplex

Double Definition:

When the clue consists of two different meanings of the same answer.
Double Definition

Anagrams:

With these clues you will have to jumble up the letters from the clue to find the answer.
Anagrams

Acrostic:

These sorts of clues means that you will have to take some of the letters (e.g. the first letter of each word, or the last letter, or every odd letter, etc.)
Acrostic Definition

Hidden Words:

When the answer is actually included within the clue itself! you just need to spot it!
Hidden Words

Reversal:

When you need to read a word or expression backwards, from right to left.
Reversal

Homophones:

The answer you have will sound similar to the actual answer you are looking for! You may have to say it out loud to find it!
Homophones

Charades:

Charades will involve joining several parts of words together to get to the final answer.
Charades

Deletion:

On occasion you will need to remove one or several letters from the clue to get to the answer.
Deletion

Cryptic Definition:

These can be quite challenging, using a confusing definition sometimes purposefully given in a somewhat misleading way.
Cryptic Definition

Complex Definition:

When you start combining several techniques within the same definition!
Complex Definition

The following Cryptic Puzzle is based on Computer Science Terminology (from the A Level Computer Science Specification).
Computer Science Cryptic CrosswordOpen Cryptic Crossword Puzzle in a New Window Spoiler alert… You can click below to reveal few tips to help you if you are completely stuck:

Tip #1
  • At least one definition in this puzzle will require you to use roman numerals
Tip #2
  • In tennis, the word “love” refers to a score of 0. Therefore, in a cryptic clue, the word love can be replaced with letter O.
Tip #3
  • In cricket, the word “duck” refers to a score of 0. Therefore, in a cryptic clue, the word love can be replaced with letter O.
Tip #4
  • In a cryptic puzzle, sailors can be a reference to the Royal Navy!
Tip #5
  • Extraordinary, broken or engineer are all indicator terms for an anagram definition!


Computer Science Cryptic CrosswordOpen Cryptic Crossword Puzzle in a New Window

unlock-access

Solution...

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

Ice Cream Price Calculator

Your local ice cream shop would like to set up a touchscreen tablet on the counter for their customers to customise their ice cream order and automatically calculate the cost of their ice cream.

Here are the options available when ordering an ice cream:

The new system will need a computer program to let the customer pick up their options for their ice cream. The customer should be able to specify:

     Whether they would like their ice cream to be served in a cup or on a cone
     How many scoops they would like to order (between 1 and 4)
     Whether they would like to add a flake
     Whether they would like to add some chocolate sprinkle
     Whether they would like to add a strawberry coulis

Based on the user inputs and the price list provided above, the system should automatically calculate and display the total price of the chosen ice cream.

Step 1: Draw a Flowchart for your algorithm

Before attempting to complete the code for this task, grab a piece of paper and draw the flowchart to identify the key inputs, decisions and calculations for your algorithm.

Alternatively, you can also create your flowchart online:
Flowchart Studio

Step 2: Complete the Python Code

Complete the Python code below.

Step 3: Add validation checks

To make your program more robust, add some validation rules on your inputs so that:

     The user can only enter one of the two options: Cup or Cone when selecting the container for their ice cream.
     The user can only enter a number between 1 and 4 when entering the number of scoops.
     The user can only enter Yes or No when asked whether they would like to add a flake, chocolate sprinkle or strawberry coulis.

You can find out more about implementing validation checks in Python using this page (input validation tab).

Step 4: Test Plan

Once your code is complete, test it using the following test plan to make sure all your calculations are correct!

Test # Input Values Expected Output Pass / Fail
#1 Container: Cone
Number of Scoops: 2
Toppings: Chocolate sprinkle
Ice Cream Price: £3.10
#2 Container: Cup
Number of Scoops: 3
Toppings: Flake and Strawberry Coulis
Ice Cream Price: £4.50
#3 Container: Cup
Number of Scoops: 6
Toppings: None
Please enter a number of scoops between 1 and 4
#4 Container: Cup
Number of Scoops: 1
Toppings: None
Ice Cream Price: £1.50
unlock-access

Solution...

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

Revision Progress Tracker Algorithm

It’s nearly the end of the school year and you have started to revise for your Computer Science end of year exam. To help you keep track of your revision, you have decided to write a computer program to calculate the percentage of revision that you have already completed.

This program will:

  • Store a list of all the topics you need to revise to get ready for your exam
  • For each topic in this list, ask you if you have completed the revision on this topic (Yes / No question)
  • Use your answers to calculate a percentage score of your progress so far using the following formula:

Flowchart

Your algorithm will be based on the following flowchart:

Python Code

Your Task is to complete the code for this algorithm!

Extension Task

Could you amend this code to read the list of topics from a CSV file instead of having these stored within the code itself. This would allow you to store a list of topics for different subjects and ask at the start of the program, which subject to track the progress of.

unlock-access

Solution...

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

Search Engine Indexing… In your own words…

Before completing this task, you will need to revise how search engine indexing works and how the page rank algorithm is used to decide which pages should appear at the top of your search results when using a search engine like Google.

You task is to write a description in your books or on the space provided below to describe, in your own words, how search engine indexing works and to describe the underlying principles of page rank algorithms used by search engines.

Spider bots Crawl 24/7
Webpage Scan/parse HTML code
Index Database Keywords
URL Page Rank Score Hyperlinks
Formula Inbound links outbound links
Search results Sort Additional parameters:
Meta tags Encryption (HTTPS) Loading Time

Search Engine Indexing and Page Rank Algorithm… in your own words!

Describe in your books or on the space provided below to describe, in your own words, how search engine indexing works and to describe the underlying principles of page rank algorithms used by search engines.




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

Average Lap Time Calculator

An Athletics club is planning to create an app to record the lap time of different runners during a 400 x 4 relay race. Their app will capture and store the names of the runners involved in the relay race and record the lap times of each runner.

Their app will then be used to generate more information using the recorded data such as:

  • The overall time it took for the runners to complete the relay race.
  • The average lap time calculated using the recorded lap times of each runner.

In the code provided below, you will find that the names and lap times of each runner are stored in the code using two lists called names and times.

runners = ["Alina","Rafael","Sid","Suraya"]
times = ["1:24","1:45","1:33","1:39"]

In the times list, lap times are expressed in minutes:seconds. For instance Alina completed her lap in 1 minute and 24 seconds whereas Rafael completed his lap in 1 minute and 45 seconds.

Then the following code is used to loop through each values in each list to display the lap time of each runner.

#Retrieve the number of runners involved in the race (e.g. 4)
numberOfRunners = len(runners)  

for i in range(0,numberOfRunners):
  print(runners[i] + " completed a lap in " + times[i])  

Your Task

Your task will be to complete the code provided below so that your Python program automatically calculates the overall time it took these 4 runners to complete the 4 x 400m relay to then work out the average lap time amongst these four runners. Make sure the overall time and the average time are given in the minutes:seconds format.

Tip?

Revealing this tip is optional! Only reveal it if you are not sure how to get started with this task!

View Tip!
To complete this task, you will first need to convert the given lap times in seconds. For instance a lap time of 1:24 means that the lap was completed in 60 + 24 = 84 seconds.

So in the for loop provided we can easily work out the lap time of each runner in seconds as follows:

for i in range(0,numberOfRunners):
  print(runners[i] + " completed a lap in " + times[i])  
  
  #convert lap time in a number of seconds
  data = times[i].split(":")
  minutes = int(data[0])
  seconds = int(data[1])
  lapTime = minutes * 60 + seconds
  
  print(runners[i] + " completed a lap in " + str(laptime) + "seconds")  

Python Code

Complete 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

Return On Investment Calculator

A group of students have setup a young enterprise at the start of the year and are now evaluating how successful their business was.

One approach to evaluate the profitability of a business is to calculate both the profit (or loss) and the Return On Investment (ROI) of the business.

To perform these calculations the business will need to provide the following information:

  • How much money was invested in the business. (e.g. total costs)
  • How much money was gained by the business. (e.g. total sales)

The profit or loss can be calculated as follows:

If the costs exceed the sales, your business will have made a loss (a negative profit!)

The Return On Investment (ROI) tells you how much money you get back for every pound you spent. It’s expressed as a percentage value.

For example, a ROI of 20% indicates that for every £1 spent, the business has raised £1,20.
An ROI of 100% means that you have doubled your investment (for every £1 spent, you have raised £2).

The formula to calcuate the ROI of a business is as follows:

Python Challenge

Write a computer program to evaluate the performance of a business. Your program will ask the user to input:

  • The total amount spent/invested on the business: Total costs
  • The total amount raised by the business: Total sales

Your program will then calculate and display the profit made by the business and indicate whether the business made a profit or a loss.
Your program will then calculate and display the Return On Investment (ROI) of the business as a percentage value.

Before attempting to write the code for this task, you may consider designing a flowchart to identify the key steps of your algorithm:
Flowchart Studio

Python Code

Your task is to complete the code below…

Test Plan

Business Name: PixelArt
Description: PixelArt is a business selling T-Shirts with a unique AI generated design printed on the back of the T-Shirt.
The main costs of the business have been to buy a stock of T-Shirts (£300). An extra £150 was also spent for running costs, stationary, packaging and advertising materials.
The business was quite successful and managed to sell all their T-shirts generating a total revenue of £1,250.

Test # Input Values Expected Output Pass / Fail
#1 Total Costs: £450
Total Sales: £1250
Profit: £800
ROI: 178%

Business Name: Podcast-101
Description: Podcast-101 is a business that produces short audio clips (jingles, radio adverts, podcasts) for their customers.
The main costs of the business have been to buy some audio recording equipment and audio editing software licenses. The business also spent some money on a social media campaign to advertise their service. In total the business invested £550 to cover all these costs.
The business did attract a few customers and created a range of radio adverts and podcasts. They generated a total income of £940.

Test # Input Values Expected Output Pass / Fail
#2 Total Costs: £550
Total Sales: £940
Profit: £390
ROI: 71%

Setting up your own Young Enterprise…

Would you be interested in setting up a Young Enterprise in your school and compete against other Young Enterprises across the UK? Find out more about the Young Enterprise scheme on: https://www.young-enterprise.org.uk/

unlock-access

Solution...

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

Storage Units Conversions – Quiz

The following diagram is a quick recap of the main storage units used to estimate the size of a file or the storage capacity of a storing device.

Take the Quiz! (open full screen)


Flappy Bird Animation using Pygame

In this blog post we are going to investigate how to animate a sprite when creating a video game using Python and the Pygame library. We will aim to create a frame-based animation using a rnage of graphics for our main sprite: a flappy bird.

Here is the animation we will recreate using Pygame

This animation contains 12 frames based on the following pictures:


Python Implementation

Below is the code to implement our sprite animation. The code consists of two files:

  • bird.py contains the Bird class which will be used to load the pictures used in our animation
  • main.py is the main frame based loop for the game.

For this code to work, you will also need to have a subfolder called images and save the above pictures of the flying bird.

bird.pymain.py
import pygame
WHITE = (255,255,255)

class Bird(pygame.sprite.Sprite):
  #This class represents a bird. It derives from the "Sprite" class in Pygame.
    
  def __init__(self, x, y):
    # Call the parent class (Sprite) constructor
    super().__init__()
    
    # Load all the images for our animation and store these in a list    
    self.images = []
    self.images.append(pygame.image.load('images/flappy-bird-1.png'))
    self.images.append(pygame.image.load('images/flappy-bird-2.png'))
    self.images.append(pygame.image.load('images/flappy-bird-3.png'))
    self.images.append(pygame.image.load('images/flappy-bird-4.png'))
    self.images.append(pygame.image.load('images/flappy-bird-5.png'))
    self.images.append(pygame.image.load('images/flappy-bird-6.png'))
    self.images.append(pygame.image.load('images/flappy-bird-7.png'))
    self.images.append(pygame.image.load('images/flappy-bird-6.png'))
    self.images.append(pygame.image.load('images/flappy-bird-5.png'))
    self.images.append(pygame.image.load('images/flappy-bird-4.png'))
    self.images.append(pygame.image.load('images/flappy-bird-3.png'))
    self.images.append(pygame.image.load('images/flappy-bird-2.png'))
    
    # Use the first image for our sprite    
    self.index = 0
    self.image = self.images[self.index]
        
    # Fetch the rectangle object that has the dimensions of the image.
    self.rect = self.image.get_rect()
    
    # Position the sprite on the screen at the given coordinates
    self.rect.x = x
    self.rect.y = y
  
  def update(self):
    # Increment the inex by 1 everytimne the update method is called
    self.index += 1
 
    # Check if the index is larger than the total number of images 
    if self.index >= len(self.images):
      # Reset the index to 0
      self.index = 0
        
    # Update the image that will be displayed
    self.image = self.images[self.index] 
# Import the pygame library and initialise the game engine
import pygame
from bird import Bird

pygame.init()
# Define some colors
BLUE = (50,150,235)

# Open a new window
size = (700, 500)

screen = pygame.display.set_mode(size)
pygame.display.set_caption("flappyBird")

#Instatiate a Bird object and set its initial position at (x=220, y=120)
flappyBird = Bird(220,120) 

#This will be a list that will contain all the sprites we intend to use in our game
all_sprites_list = pygame.sprite.Group()

# Add our flappyBird object to the list of sprites
all_sprites_list.add(flappyBird)

# The loop will carry on until the user exits the game (e.g. clicks the close button).
carryOn = True
 
# The clock will be used to control how fast the screen updates
clock = pygame.time.Clock()
 
# -------- Main Program Loop -----------
while carryOn:
    # --- Main event loop
    for event in pygame.event.get(): # User did something
        if event.type == pygame.QUIT: # If user clicked close
              carryOn = False # Flag that we are done so we exit this loop
        elif event.type==pygame.KEYDOWN:
                if event.key==pygame.K_x: #Pressing the x Key will quit the game
                     carryOn=False  
 
    # --- Game logic should go here
    all_sprites_list.update()
 
 
    # --- Drawing code should go here
    # First, clear the screen to blue (sky). 
    screen.fill(BLUE)
    
    #Now let's draw all the sprites in one go. (For now we only have 1 sprite!)
    all_sprites_list.draw(screen) 
 
    # --- Go ahead and update the screen with what we've drawn.
    pygame.display.flip()
     
    # --- Limit to 60 frames per second
    clock.tick(60)
 
#Once we have exited the main program loop we can stop the game engine:
pygame.quit()
Tagged with:

Adding a Timer using Python

In this blog post we will investigate how we implement a timer to add in any of our Python game/projects. To do so we will use the time library in Python.

So, to import the time library we will add the following line of code at the top of our code:
import time

To initialise our timer by deciding on the duration of the game (allocated time) measured in second. For instance, for a 1 minute game we will set the allocated time to 60s.
allocatedTime = 60

When the game start we will take a timestamp to record the time the game started.
startTime = time.time()

At any stage during the game, we can measure the number of seconds since the beginning of the game using the following instruction:
elapsedTime = time.time() - startTime

We can then compare this with the allocated time to see if it’s time over!

if elapsedTime >= allocatedTime:
   print("Game Over")

Let’s combine the above steps to complete our timer based on the following flowchart:

The Python code would be as follows:

import time

allocatedTime = 60
startTime = time.time()
gameOver = False

while gameOver==False:
   
  # Add Code for the game...
  time.sleep(1)

  elapsedTime = time.time() - startTime
  if elapsedTime >= allocatedTime:
     gameOver = True

print("Game over!")


Pass The Bomb

Let’s see a complete example of a game using a timer. The code below is for a game of “Pass the bomb”, where several players are passing a bomb to one another. The player holding the bomb has to answer a question. (e.g. Can you think of a word containing the letters “CO”?). The bomb is set with a random delay before it explodes. After answering the question, the game checks if the timer for the bomb has expired and hence the bomb has exploded. In this case, the player is removed from the game, the timer for the bomb is reset and the game carries on till there is only one player left.

The MafiaBoy dDoS attack

This post is part of series of blog posts investigating different impacts of UK legislation relevant to Computer Science with a particular focus on:

  • Data Protection Legislation
  • Intellectual Property Protection (incl. Copyright and Trade Marks legislation)
  • Computer Misuse Act (1990)

The MafiaBoy dDoS Attack: Unveiling Cyber Vulnerabilities And The Need For Legal Safeguards To Combat Cyber-Criminality.

The MafiaBoy dDoS attack:
In the early days of the internet, the world witnessed a watershed moment in cyber history: the MafiaBoy dDoS attack. In the year 2000, a 15 year-old Canadian teenager, known as “MafiaBoy”, unleashed a series of devastating distributed denial-of-service (dDoS) attacks that brought some of the internet’s giants to their knees. Using a network of compromised computers, or botnet, MafiaBoy orchestrated a coordinated assault on high-profile websites, including Yahoo!, Amazon, and eBay. By flooding these websites with a deluge of traffic, he rendered them inaccessible to legitimate users, causing widespread disruption and financial losses. The MafiaBoy dDoS attack highlighted the ease with which malicious hackers could disrupt the internet. What motivated a teenager to unleash such chaos? For MafiaBoy, it was a combination of curiosity, thrill-seeking, and a desire to prove his technical prowess.

The repercussions of the MafiaBoy attack were profound, prompting governments and law enforcement agencies worldwide to reassess their approach to cybercrime. In Canada, where Calce resided, the incident catalysed legislative action culminating in the enactment of the Canadian Cybercrime Act in 2001. Meanwhile, in the United Kingdom, the Computer Misuse Act (CMA) of 1990 emerged as a critical legal instrument in combating similar acts of cyber trespass and sabotage.

The Computer Misuse Act (1990) – UK Legislation
The CMA criminalises unauthorised access to computer systems, unauthorised access with intent to commit further offenses, and unauthorised acts with intent to impair the operation of a computer. Under the provisions of the CMA, individuals found guilty of launching dDoS attacks can face severe penalties, including fines and imprisonment. By establishing clear legal boundaries and consequences for cyber misconduct, the CMA serves as a deterrent against such malicious activities.

The Computer Misuse Act, was conceived prior to the MafiaBoy attack, in an era when the internet was still in its infancy. The Act outlined three main offenses:

Unauthorised access to computer material: This provision criminalises the act of gaining unauthorised access to computer systems, whether by bypassing security measures or exploiting vulnerabilities. It covers a broad spectrum of activities, from hacking into personal email accounts to infiltrating corporate networks.

Unauthorised access with intent to commit or facilitate further offenses: Building upon the first offense, this provision targets individuals who gain unauthorised access to computer systems with the intention of committing additional crimes, such as data theft, fraud, or sabotage. It recognises the inherent danger posed by hackers who exploit their access for malicious purposes.

Unauthorised modification of computer material: This offense pertains to the deliberate alteration, deletion, or manipulation of computer data without proper authorisation. It encompasses acts of cyber vandalism, where perpetrators deface websites or corrupt digital records for malicious ends.

Conclusion
In conclusion, the MafiaBoy dDoS attack served as a wake-up call to the vulnerabilities of the digital landscape, prompting governments to enact legislation to combat cybercrime. In the United Kingdom, the Computer Misuse Act stands as a cornerstone of cybersecurity governance, providing the legal framework necessary to address dDoS attacks and other forms of cyber misconduct.


Disclaimer
This article was generated with the help of ChatGPT, an artificial intelligence language model developed by OpenAI, and is provided for educational purposes. The content is created based on general knowledge and may not be fully accurate. It is not intended to be a substitute for professional advice.
Question 1[2 marks]

What was the significance of the MafiaBoy dDoS attack, and how did it impact high-profile websites?




Question 2[2 marks]

What is a “botnet” and how is it used in the context of a dDos attack?




Question 3[2 marks]

What motivated MafiaBoy to orchestrate the dDoS attacks?




Question 4[2 marks]

What are the main provisions of the Computer Misuse Act (CMA) in the United Kingdom?




Question 5[2 marks]

Under the computer Misuse act, what penalties can hackers face for conducting a dDos attack in the UK?





Save / Share Answers as a link

unlock-access

Solution...

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