More results...

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

Min, Max, Mean, Median and Mod

maths-blackboardIn this Python challenge we will manipulate a list of numbers to calculate the Min, Max, Mean, Median and Mod of all these numbers.

First you may want to refresh your maths skills and check the meaning of these terms: http://www.purplemath.com/modules/meanmode.htm

Our Python code will first generate a random list of numbers.

We then added a few lines of code to calculate the min value. Your task is to complete this code to calculate the max, mean, median and mod values using a similar approach.


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 Breaker Challenges – Series 1

padlock-closed

Crack the Codes! (open full screen)


In this set of challenges, you will analyse some pseudocode to try to get the pass codes required to move on to the next levels. Levels will get more and more complex as your progress through these challenges. Will you be able to crack all the codes?

Tagged with:

Computer Networks – Quiz!

Take the Quiz! (open full screen)


Tagged with: ,

Algorithm Terminology – Quiz!

Take the Quiz! (open full screen)


How old will you be in…

In this challenge we will write a Python program to help us find out hold we will be in the coming years! We have designed the algorithm of our program using both a Flowchart and Pseudocode.

Algorithm

FlowchartPseudocode
how-old-flowchart

year = 2017
age = INPUT("How old are you?")
FOR i FROM 1 TO 50
   year = year + 1
   age = age + 1
   OUTPUT("In " + year + ", you will be " + age + " years old.")
END FOR

Reviewing the Algorithm


Check the above pseudo-code and answer the following questions:


?
What variables are used in this code?


?
On what line is iteration used?


?
What value is used to initialise the variable year?


?
On what line is the variable age incremented?


?
On which line is string concatenation used?


?
How many lines will be displayed on screen once this program has been fully executed?


?
What would be the last line to appear on screen once this program has been fully executed?

Check the above flowchart and answer the following questions:


?
In a flowchart, what shape is used to represent a user INPUT?


?
In a flowchart, what shape is used to represent iteration?


?
In a flowchart, what shape is used to represent an OUTPUT?

Python Code


Your task is to use the algorithm provided above (either Flowchart or Pseudo-code) to code this algorithm using Python.

unlock-access

Solution...

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

Tagged with: , ,

Sampling Sound – Revision

sampling-interval-15
Before attempting this task make sure you understand what is meant by sampling sound.
Complete this drag and drop activity to highlight the key concepts of sound sampling.

digital
large
sampling rate
analogue
quality
Hz
milliseconds
bps
measurements
lower
bits
intervals

Sampling Intervals and Sample Rate

  • Sampling sound is the process of converting an sound wave into a signal.
  • When sampling sound, the computer takes of the sound wave at regular .
  • The sampling interval is the number of between two samples.
  • The larger the sampling interval, the the quality and file size of the sound file.
  • The is the number of samples in one second. It is measured in .
  • A sample interval leads to a low sample rate.

Bit Depth and Bit Rate

  • The Bit Depth is the number of used to store one sample into binary.
  • A high bit depth leads to a better sound file.
  • The Bit Rate is the number of bits used per seconds, measured in .
  • A high bit rate leads to a better quality sound file.

Sampling Sound

microphone-sampling-soundSampling is a method of converting an analogue audio signal into a digital signal. While sampling a sound wave, the computer takes measurements of this sound wave at a regular interval called sampling interval. Each measurement is then saved as a number in binary format.

Sampling Interval


The quality and file size of the sound files are linked to the size of the sampling interval (in milliseconds).

Sampling Interval: 15 ms

Sampling Interval: 15 ms

Sampling Interval: 40ms

Sampling Interval: 40ms

A small sampling interval results in a better quality sound file and increases the size of the audio file.

Sample Rate


To describe the quality of a sound file we often use the term sample rate as opposed to the sampling interval.

The sample rate (in Hz) is the number of samples in one seconds.

Sample Rate = 1 / Sampling Interval
Sampling Interval: 15 ms

Sample Rate: 66Hz

Sampling Interval: 40ms

Sample Rate: 25Hz

A small sampling interval results in a high sample rate which results in a better quality sound file and increases the size of the audio file.

Sampling Sound Visualisation using Python


Bit Depth


Bit depth is the number of bits available for each sample. The higher the bit depth, the higher the quality of the audio. Bit depth is usually 16 bits on a CD and 24 bits on a DVD.

Bit Rate


The bit rate of a file tells us how many bits of data are processed every second. Bit rates are usually measured in kilobits per second (kbps). The higher the bit depth, the higher the quality of the audio.

Take the Quiz


Take the Quiz on Sampling Sound

Vanishing Point Perspective

In graphical perspective, a vanishing point is an abstract point on the image plane where 2D projections (or drawings) of a set of parallel lines in 3D space appear to converge. The vanishing point may also be referred to as the “direction point”.

perspective-vanishing-point-1

Vanishing Point Perspective is used in Graphic editing and 3D video games. It can be used to render 3D shapes (3D Buildings and objects), add perspective to a background scene (road, train track) or add shadow effects.

The following slideshow, demonstrates the use of vanishing points in computer graphics:

You can read more about Vanishing Point Perspective on Wikipedia.

Vanishing Point Perspective using python Turtle


Falling/Scrolling Object Algorithms

rocketIn many arcade video games objects are flying across the screen (either vertically: falling objects, upcoming cars in car racing game) or horizontally (e.g. pipes in Super Mario or flappy bird, cars in Crossy Road).

In frame based games, motions is often implemented by positioning sprites on the screen using (x,y) coordinates and applying a velocity vector (Vx,Vy) to each sprite to indicate the direction and speed of the sprite.

Let’s review the algorithms used to implement three types of motions:

  • Vertical Scrolling: Falling objects (e.g. Catch the Fruit game)
  • Horizontal Scrolling (Right to left gliding pipes in Super Mario)
  • Combination of both Vertical and Horizontal Scrolling in the game of Space Invaders

Vertical Scrolling: Falling objects


scrolling-algorithm-falling-object

Horizontal Scrolling:


scrolling-algorithm-pipe

Space Invaders: Aliens Motion


scrolling-algorithm-space-invaders


Tagged with:

Computational Features of Video Games

spaceInvaderIf you are confident enough with your Python skills, you might feel ready to move on to the next stage and start creating your own arcade video game.

To do so you will have to research and investigate existing video games to identify some of the key computational features of these games and see how these can be implemented.

For arcade games we advise you to investigate the classic games including:

When investigating these video games try to identify their main features:

  • What are the main sprites of the game,
  • How does the player interact with the game / control the main sprite,
  • How does the scoring system work,
  • Is the game making use of a timer,
  • Can the player play against the computer,
  • Is the game using real physics,
  • Is the game in first-person view,
  • How does the computer control the movement of other sprites,
  • How does the computer decide what move to play next,
  • What information is stored in the game,
  • What extra features are included in the games (e.g. leaderboard?),
  • What settings can be changed in the game,
  • Are there multiple levels of difficulty,
  • What makes a level more difficult to complete,
  • How is the stage generated,
  • What are the main characteristics of the Graphical User Interface,
  • etc.

You will then be able to research these characteristics further and identify the computational features that you could use to build your own game.

To help you getting started we have listed here a few blog posts from this blog describing a range of computational features further:

Controlling Movement of Sprites:


Main Program Loop (Frame Based Game)

Main Program Loop (Frame Based Game)

Controlling a Sprite using the arrow keys

Controlling a Sprite using the arrow keys

Edge Detection & Bouncing Algorithm

Edge Detection & Bouncing Algorithm

Scrolling/Falling Object Algorithms

Scrolling/Falling Object Algorithms

Projectile-Motion

Projectile Motion Formula

Pacman Ghost Algorithm

Pacman Ghost Algorithm

Polar vs. Cartesian Coordinates

Polar vs. Cartesian Coordinates

Translations and Rotations in a 2D frame by frame animation

Translations and Rotations in a 2D frame based animation

2D Rotation Matrix

2D Rotation Matrix

Elastic Collision Formulas

Elastic Collision Formulas

Snake Game in Python

Stage Generation:


Random Background Generation Algorithm

Random Background Generation Algorithm

Parallax Scrolling Effect

Parallax Scrolling Effect

Battleship Grid Initialisation Algorithm

Battleship Grid Initialisation Algorithm

Level Generation using a 2D Array

Level Generation using a 2D Array

Pacman Maze using a 2D Array

Snakes & Ladders using a 2D array

Candy Crush – Level Generation

Collision Detection Algorithms:


Collision Detection Algorithm in a game of Curling

Collision Detection Algorithm in a game of Curling

Collision Detection between Sprites (PyGame)

Collision Detection between Sprites (PyGame)

Target Detection Algorithm

Target Detection Algorithm

Bouncing Algorithm in a platform game

Bouncing Algorithm (platform game)

Data Structures:


Connect4 Data Structure using a 2D-array

Connect4 Data Structure using a 2D-array

Othello Data Structure using a 2D-array

Othello Data Structure using a 2D-array

File Handling (CSV files) in a Monopoly Quiz

File Handling (CSV files) in a Monopoly Quiz

Using a 2D-array to implement a game of Tetris

Using a 2D-array to implement a game of Tetris

Using Lists/Arrays and Graphs to store/represent data

Using Lists/Arrays and Graphs to store/represent data

Using a Dictionary: Chemical Element Quiz

Using a Dictionary: Chemical Element Quiz

2D array - Minesweeper (Javascript)

2D array – Minesweeper (Javascript)

Football Results Tracker using a CSV file

Football Results Tracker using a CSV file

Frog Puzzle - Backtracking Algorithm using a Graph Data Structure

Frog Puzzle – Backtracking Algorithm using a Graph Data Structure

Noah's Ark - A backtracking algorithm based on a 2D array data structure.

Noah’s Ark – A backtracking algorithm based on a 2D array data structure.

 Laser Game - 2D array data structure.

Laser Game – 2D array data structure.

Scoring Systems:


Scoring System in a Quiz

Scoring System in a Quiz

Archery Scoring System

Archery Scoring System

Darts Scoring System

Darts Scoring System

Grading System

Grading System

Data Visualisation


Data Visualisation Algorithms

Data Visualisation Algorithms

Artificial Intelligence? When the player plays against the computer!


Tic-Tac-Toe Challenge

Using a Backtracking algorithm to solve a Sudoku Puzzle

Using a Backtracking algorithm to solve a Sudoku Puzzle

Using a backtracking algorithm to explore a maze.

Using a backtracking algorithm to explore a maze.

Heuristic approaches to problem solving

Heuristic approaches to problem solving

Machine learning top trumps game

Machine learning top trumps game

Rush Hour

Rush Hour: Backtracking Algorithm & Heuristics

Connect Flow - Backtracking Algorithm & Heuristics

Connect Flow – Backtracking Algorithm & Heuristics

3D User Interface:


Oblique Projection Formula

Oblique Projection Formula

3D Rotation Matrix

3D Rotation Matrix

Vanishing Point Perspective

Vanishing Point Perspective

Additional Features of video games:


Adding a timer in a video game

Sprite Animation using Pygame

Login Algorithm

Login Algorithm

Leaderboard (using a CSV file)

Leaderboard (using a CSV file)

Off-side Detection Algorithm

Off-side Detection Algorithm

Closest Player Detection Algorithm

Closest Player Detection Algorithm

Manhattan (taxicab) distance calculator

Manhattan (taxicab) distance calculator

Shuffling Algorithm (Shuffling a deck of cards)

Shuffling Algorithm (Shuffling a deck of cards)

Object-Oriented Programming:


OOP Concepts

OOP Concepts

Pong (Pygame Tutorial)

Pong (Pygame Tutorial)

Car Racing Game (Pygame Tutorial)

Car Racing Game (Pygame Tutorial)

Breakout Game (Pygame Tutorial)

Breakout Game (Pygame Tutorial)

UML Diagrams

UML Diagrams


Tagged with: