More results...

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

3D Printing – Name Badge

One application of programming is to control 3D printers to create 3D models. Using a Block programming language you can create your own 3D models and export them in a format recognised by 3D Printers. In this blog you will create a 3D model of your name or initials using http://www.beetleblocks.com/.

We have To get you started we are showing the code that would be used to create two leetes: Letter C and letter A.

You will need to use a similar approach to create a 3D model of your initials or of your full name.

Letter C


3D-Printing-Letter-C

Letter A


Letter A

Students’s Code


Tagged with: ,

3D Printing: Bracelets

One application of programming is to control 3D printers to create 3D models. Using a Block programming language you can create your own 3D models and export them in a format recognised by 3D Printers. In this blog we will create some bracelets using http://www.beetleblocks.com/.

We have made 2 Bracelets that you can easily reproduced and tweak to create your own bracelet.

Notice how both Bracelets use iteration (repeat block) which make the code very short and effective to produce a complex 3D model.

Bracelet #1


Bracelet #2


Tagged with: ,

Conway’s Game of Life

Game_of_life_pulsarThe “game” is a zero-player game, meaning that its evolution is determined by its initial state, requiring no further input. One interacts with the Game of Life by creating an initial configuration and observing how it evolves, or, for advanced “players”, by creating patterns with particular properties.

The universe of the Game of Life is an infinite two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, alive or dead, or “populated” or “unpopulated”. Every cell interacts with its eight neighbours, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:

  • Any live cell with fewer than two live neighbours dies, as if caused by underpopulation.
  • Any live cell with two or three live neighbours lives on to the next generation.
  • Any live cell with more than three live neighbours dies, as if by overpopulation.
  • Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

The initial pattern constitutes the seed of the system. The first generation is created by applying the above rules simultaneously to every cell in the seed—births and deaths occur simultaneously, and the discrete moment at which this happens is sometimes called a tick (in other words, each generation is a pure function of the preceding one). The rules continue to be applied repeatedly to create further generations.

You can read more about Conway’s Game of Life on wikipedia.

Python Implementation


Our Python implementation of Conway’s Game of Life lets you try different starting configurations as follows:

  • Option 1: Random configuration using a randomly generated 15×15 grid.
  • Option 2: The Glider Configuration.Glider
  • Option 3: The Toad Configuration.Toad
  • Option 4: The Beacon Configuration.Beacon
  • Option 5: The Pulsar configuration.Pulsar

Your Challenge


Compete the code provided in the trinket above to add some additional configurations such as:

  • The BlinkerBlinker
  • The PentadecathlonPentadecathlon
  • The Lightweight SpaceshipLightweight Spaceship

3D Staircase Challenge

In this challenge you will use http://www.beetleblocks.com/ to create some 3D models to represent different types of staircases. I will use iteration (for loops) to make your code more effective and investigate the use of (x,y,z) coordinates to create your models.

Another approach for this challenge is to complete the following tasksheet to match the code with the corresponding 3D model:

– 3D-Staircase-Challenge.pdf –

Staircase #1


ChallengeSolution

Staircase #2


ChallengeSolution
staircase-2-3d-model

Staircase #3


ChallengeSolution


Staircase #4


ChallengeSolution


Staircase #5


ChallengeSolution


Tagged with: , , ,

Space Exploration – 3D Models

Computer code can be used to create 2D or 3D graphics. The code used to create these graphics can then be used by 3D printers to create objects.

In this challenge we will use block programming to create a 3D model of a space station or a lunar habitat.

Here are some models to be used as a source of inspiration:
Apolo-Soyuz

Apolo Soyuz

Habitat_Demo_Unit
Habitat Demo Unit

Skylab-3D
Skylab

Your Challenge


To recreate your own Space Exploration 3D Model online you will need to access: http://www.beetleblocks.com.

You can create your own model from scratch or reuse the code provided below to get started:
3D-Space-Exploration

3D-Space-Exploration-Code

Tagged with: , ,

Python Wordsearch Generator

wordsearchFor this challenge we will write a Python program to randomly generate a 12 by 12 wordsearch where computing words will be randomly positioned on the grid and will appear either horizontally, vertically or diagonally.

We have started the code for you but one of our subroutine is incomplete. This is the addWord() subroutine used to position a word on the wordsearch. Your task is to complete the code to:

  • Decide where the word will start (random row and column)
  • Decide if the word will be added horizontally, vertically or diagonally
  • Check that the word will fit in (within the 12 by 12 grid)
  • Check that the word will not overlap with existing letters/words in the wordsearch

Complete the Code


Extension Task


Add two constants called ROWS and COLS both sets to 12. Make sure you declare and initialise these constants at the very beginning of your code.

Ensure that your code is using these constants throughout so that you can easily change the final size of the wordsearch by changing these two values only once at the beginning of your code.

unlock-access

Solution...

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

London Bus Timetable

london-tourFor this challenge, we will write a Python script to extract relevant information from a bus timetable to help end-users plan their journey.

Check the following timetable to answer the questions listed below:
bus-timetable

  • At what time will I reach Buckingham Palace if I take the 11:45 bus from St Paul’s Cathedral?
  • At what time will I reach Oxford Circus if I take the 14:44 bus from Tower Bridge?
  • I am planning to finish the visit of Tate Modern around 10:00? What would then be the earliest time for me to be at Covent Garden?

Python Challenge


We have started some code to load the content of the above timebale into a 2-dimensional array (list of lists in Python) called timetable.

Your task is to complete the code to:

  • Asks the user for the bus station they will take the bus from,
  • Asks the user at what time they will be at the bus station,
  • Asks the user where do they want to go,
  • Outputs the earliest time the user can reach their destination.


unlock-access

Solution...

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

Offside Detection Algorithm

In a game of football, one of the most complex rule is the offside rule. One of the roles of the assistant referees is to detect when a player is offside.

A player is in an offside position if, when the ball is played by a team-mate, they are nearer to the opposition’s goal line than both the ball and the second last defender (the last defender being in most cases the goal keeper).

Note that players cannot be offside in their own half of the field.

In this challenge, we assume that the blue team has the ball and want to identify if any of the players of the blue team is in a position of off-side. We will assume that the ball is being played by a team-mate positioned behind them.

Python Challenge


In this challenge you will design an algorithm to detect if a player is offside. You will implement this algorithm in Python by completing the code provided below.

Your algorithm will need to:

  • Loop through all the players of the red team (away team) to find out the y coordinate of the second last defender,
  • Loop through all the players of the blue team (home team) to find out the y coordinate of the most forward player,
  • Compare both these y coordinates to decide if there is a position of offside,
  • Output a message on screen or draw a horizontal line to show which player is offside.

unlock-access

Solution...

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

Connect4 Challenge

connect4In this blog post you will use HTML, CSS, and JavaScript to complete this game of connect 4 for two players. (Rules of the game)

You will first need to reverse-engineer the code provided. The code so far is used to:

  • Display the 6×7 grid using HTML and CSS.
  • Add a token on the bottom row of the grid when the user clicks on a column of the grid using the selectColumn()
    function in JavaScript.
  • Refresh the grid on the screen using the refreshGrid() function in JavaScript.

The code provided uses a variable called grid, use to store a two-dimensional array (6×7) of integer values. Within this array, a 0 represents an empty place, a 1 represents a yellow token and a 2 represents a red token.

2-dimensional array

Your Task


Your task consists of:

  • Amend the selectColumn() function in JavaScript in order to:
    • Check if the column is not already full and if it is ask the user to chose another column.
    • Place the token on top of any existing token in the selected column.
    • Check if after placing the token the game continues or if the player has aligned 4 tokens. (Current player wins!)
    • Check if the grid is full (Game ends on a draw!)
  • Add code to the resetGrid() JavaScript function to start a new game with an empty grid.

HTML, CSS and JavaScript Code


Edit this code in a new window using this button:

Tagged with: , , , , ,

Water Polo Challenge

water-poloIn this challenge you are going to use Python code to score a goal in a game of Water Polo.

To do so you will use the code given below. You will pass the ball from one player to another using a subroutine called throwBall(). This subroutine takes two parameters as follows:

  • angle: an integer value between 0 and 360 degrees to represent the direction of the throw. (e.g 0° would throw the ball to the right, 90° straight ahead and 180° to the left).
  • power: an integer value between 0 and 200 representing how far you can throw the ball.

This diagram will help you identify your angles when throwing the ball:angle-0-to-360

In this challenge you have the red team. Make sure than, when passing the ball or trying to score a goal (in the goal at the top), you do not throw the ball over a white player who would then intercept it. Also make sure that each throw either reach a team member (red team) or the top goal.

Complete the code to score a goal


Tagged with: , ,