More results...

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

Merry Christmas

merry-christmasFor this challenge we are going to create Christmas Cards using Python turtle.

We will use the random library to create unique cards.

Starry Night


Our first card consists of creating a starry night scene.

This card is using:

  1. A function called draw_star() that takes five parameters: myPen, colour code, x position, y position and size of the star,
  2. Iteration: A for loop to create 15 stars,
  3. x and y coordinates to position the stars on the canvas,
  4. The random library, using the randint() function to randomly position the stars on the canvas.

(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:

Christmas Tree


Our second card consists of creating a Christmas Tree.

This card is using:

  1. A function called draw_rectangle() that takes six parameters: myPen, colour code, x position, y position, width and height of the rectangle,
  2. Iteration: A while loop to add more layers to the tree till we reach a thin enough top layer,
  3. x and y coordinates to position the rectangles on the canvas,
  4. The random library, using the randint() function to randomly set the width and height the rectangles on the canvas.

Tweak this card:
What’s about adding 20 snowflakes behind this tree, using the draw_circle() function.
Make sure the snowflakes are randomly positioned on the canvas.

Your Challenge


Your challenge consists of creating one of the following three Christmas cards:
xmas-cards

Make sure that your code uses:

  1. The randint() function from the random library to make sure each snowman, tree or hat is unique,
  2. A loop to reduce the number of instructions in your code.

unlock-access

Solution...

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

Sequencing, Selection & Iteration

When you write lines of code, there are three ways you can control the order these lines will be executed by the computer:

  1. Sequencing: This means that the computer will run your code in order, one line at a time from the top to the bottom of your program. It will start at line 1, then execute line 2 then line 3 and so on till it reaches the last line of your program.
  2. Selection: Sometimes you only want some lines of code to be run only if a condition is met, otherwise you want the computer to ignore these lines and jump over them. This is achieved using IF statements. e.g. If a condition is met then lines 4, 5, 6 are executed otherwise the computer jumps to line 7 without even looking at line 4,5 and 6.
  3. Iteration: Sometimes you want the computer to execute the same lines of code several times. This is done using a loop. There are three types of loops: For loops, while loops and repeat until loops. That’s handy as it enables you not to have to copy the same lines of code many times.

Take the quiz (open full screen):


Tagged with: , , ,

Vector Based Graphics

Computers can use two types of graphics:

  • Bitmaps: A bitmap (or raster graphic) is a digital image composed of a matrix of dots. When viewed at 100%, each dot corresponds to an individual pixel on a display. In a standard bitmap image, each dot can be assigned a different colour.
  • Vector-based graphics: Unlike bitmap graphics, vector graphics are not made up of a grid of pixels. Instead, vector graphics are made of mathematical/geometric instructions known as “paths”. A path can be a line, a square, a triangle, or a curvy shape. A path is defined by a start and an end point, along with other points, curves, and angles along the way. These paths can be used to create simple drawings or complex diagrams.

The purpose of this blog post is to demonstrate what vector based graphics consist of and how they are stored on the computer.

SVG is a format used to create vector based graphics.

See the codepen below to see how the following graphic is created using SVG code. Click on “Edit on CODEPEN” to tweak this code and change this graphic.

See the Pen Vector Based Graphic by 101 Computing (@101Computing) on CodePen.

Check this page from w3schools.com to learn about SVG graphics that can be used directly into an HTML5 page.

Your Challenge


Pick any graphic from the Christmas collection or from the Science collection below and try to recreate this graphic using SVG code (by editing the above CodePen).

Christmas Collection
xmas-graphics

Science Collection
science-graphics

Tagged with: , , , ,

Computing Operators

While programming with high-level languages such as Python, you will use four different types of operators as follows:

  • The assignment operator ( = ) which is used to assign a value to a variable or a constant.
  • Arithmetic operators ( +, -, *, / ) which are used to perform mathematical calculations.
  • Comparison operators ( >, <, >=, <=, ==, != ) which are used to compare values.
  • Boolean operators ( AND, OR, NOT ) which are often used to complete more than one comparison.

Match the dominoes!


Click on the picture below to start:
operators-dominoes

Tagged with: , , , ,

Beach Huts Challenge

beach-hutsLook at the code below to draw lines of beach huts.

(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

Your task is to tweak the code used to draw the third line of beach huts. On this line we want the computer to choose random colours from the colour list – that’s already the case! However this time we want to make sure that we cannot have two beach huts of the same colour next to each other.


unlock-access

Solution...

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

Operators Quiz

While programming with high-level languages such as Python, you will use four different types of operators as follows:

  • The assignment operator ( = ) which is used to assign a value to a variable or a constant.
  • Arithmetic operators ( +, -, *, / ) which are used to perform mathematical calculations.
  • Comparison operators ( >, <, >=, <=, ==, != ) which are used to compare values.
  • Boolean operators ( AND, OR, NOT ) which are often used to complete more than one comparison.

Take the Quiz! (open full screen)

Guess the country

globeFor this challenge we are going to create a game where the user plays against the computer.

The aim of this game is to guess the name of a country. The computer will give the player clues to help them identify the country. The aim for the player is to try to guess the country using as few clues as possible.

For this challenge we are going to work from a flowchart that describes the algorithm we will base our code on: (Click on the picture to zoom in)

GuessTheCountry

Let’s get coding


We have started the code for you. Use the flowchart above to complete this code.

Extension task #1


Could you tweak this code to display at the end how many clues have been used in total to guess the country.

Extension task #2


This code only works with one country.

How could we change it to have a list countries and a list of clues for each country and get the computer to randomly choose one country from the list of countries.

Tip: To solve this task you may want to investigate how to use a list of lists in Python.

Tagged with: , ,

Question Time

Feeling confident with your computing knowledge?

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


?
Why are there around 16 milion colours in the RGB colour palette?


?
Why would a text file containing 3,000 characters use around 3 kilobytes?


?
Why are there 1024 (and not 1000) bits in a kilobyte?


?
Why do we use RGB colour codes when the three primary colours are Red, Yellow and Blue.


?
What is the expression:
= != ==
telling us?


?
Is the boolean expression:
(NOT A) AND (NOT B)
the equivalent of
NOT (A OR B)

?


?
How can we tell that #333333 is a darker grey colour than #AAAAAA?


?
How can we tell that #FF00FF is a magenta/purple colour?


?
Why do we store phone numbers or credit card numbers as strings and not integers?


?
Why do bitmap pictures pixelate when they are resized/enlarged but vector-based pictures don’t?


?
What is the maximum number of devices that we can connect on the Internet at the same time (using IPv4)?


?
Does it take longer to download a file from a sever located in Australia or in Europe?


?
How does internet data cross the Atlantic Ocean?


?
How does Google search the entire web in just a few milliseconds?


?
Would it be possible for a computer to have a sense of humour?

Secret Code

In this challenge we are putting your deciphering skills to the test.

Here are your secret codes. Will you be able to decode these?

Cipher #1

0101010001101000011001010010000001000001010100110100001101001001010010010010000001100011011011110110010001100101001000000110100101110011001000000111010101110011011001010110010000100000011101000110111100100000011000110110111101101110011101100110010101110010011101000010000001110100011001010111100001110100001000000111010001101111001000000110001001101001011011100110000101110010011110010010000001100011011011110110010001100101001000010010000001010100011010000110010100100000010000010101001101000011010010010100100100100000011000110110111101100100011001010010000001100011011011110110111001110100011000010110100101101110011100110010000000110001001100100011100000100000011000110110100001100001011100100110000101100011011101000110010101110010011100110010111000100000010101000110100001100101001000000110010101111000011101000110010101101110011001000110010101100100001000000100000101010011010000110100100101001001001000000110001101101111011001000110010100100000011000110110111101101110011101000110000101101001011011100111001100100000001100100011010100110110001000000110001101101000011000010111001001100001011000110111010001100101011100100111001100101110

Cipher #2

\u0055\u006e\u0069\u0063\u006f\u0064\u0065 \u0069\u0073 \u0061 \u0063\u0068\u0061\u0072\u0061\u0063\u0074\u0065\u0072 \u0073\u0065\u0074 \u0075\u0073\u0069\u006e\u0067 \u0032 \u0042\u0079\u0074\u0065\u0073 \u0070\u0065\u0072 \u0063\u0068\u0061\u0072\u0061\u0063\u0074\u0065\u0072 \u0077\u0068\u0069\u0063\u0068 \u006d\u0065\u0061\u006e\u0073 \u0069\u0074 \u0063\u0061\u006e \u0072\u0065\u0070\u0072\u0065\u0073\u0065\u006e\u0074 \u006d\u006f\u0072\u0065 \u0074\u0068\u0061\u006e \u0036\u0035\u002c\u0030\u0030\u0030 \u0075\u006e\u0069\u0071\u0075\u0065 \u0063\u0068\u0061\u0072\u0061\u0063\u0074\u0065\u0072\u0073\u002e \u0054\u0068\u0069\u0073 \u0069\u0073 \u0077\u0068\u0079 \u0075\u006e\u0069\u0063\u006f\u0064\u0065 \u0069\u0073 \u0075\u0073\u0065\u0064 \u0074\u006f \u0065\u006e\u0063\u006f\u0064\u0065 \u004a\u0061\u0070\u0061\u006e\u0065\u0073\u0065 \u0063\u0068\u0061\u0072\u0061\u0063\u0074\u0065\u0072\u0073 \u0028\u0065\u002e\u0067 \u6628\u002c\u591c\u002c \u6700\u002c\u9ad8\u0029 \u006f\u0072 \u0041\u0072\u0061\u0062\u0069\u0063 \u0063\u0068\u0061\u0072\u0061\u0063\u0074\u0065\u0072\u0073 \u0028\u0065\u002e\u0067\u002e \u0635 \u002c\u0639 \u0634 \u002c\u062c\u0029\u002e
Tagged with: , , ,

Data Types Quiz

When using variables and constants in your programs it is important to use the correct data types.

The main data types are:

  • Integer: for whole numbers only such as 7,
  • Float/Real: for numbers with decimals only such as 9.81,
  • String: for piece of text. It can also include number digits and punctuation signs. e.g. “IP4 5HD”, “Hello world!”,
  • Boolean: for values which are either True or False,
  • Date & Time: for dates! (With or without a time): e.g. 31/12/2015 00:00:00, 25/12/2015

Test your knowledge of Data Types (open full screen):


Tagged with: