It’s almost impossible to discuss graphics software without first establishing an understanding of the differences between the two major graphic types: bitmap and vector images.
The following “fill in the blank” activities will test your understanding of the characteristics of both types of graphics.
Bitmap/Raster GraphicsVector Based Graphics
Bitmap/Raster Graphics
pixels
Raster
(0,0,0)
million
tiny dots
resolution
PNG
Green
digital
8 mega pixels
(0,185,185)
scanner
Bitmap images (also known as images) are made up of in a grid. Pixels are picture elements; of individual colour that make up what you see on your screen. Pixels are defined by 2 properties: their position on the picture/grid and their colour value. These properties are stored in a bitmap file for every single pixel in the picture.
The colour value of each pixel is determined by the RGB colour code. (Red Blue). Each colour is made of a mix of these 3 primary colours. Each of these 3 colour have a value between 0 and 256. Hence a bitmap can have up to 256* 256 * 256 = 16 possible shades.
Red: (255, 0, 0)
Purple: (85,0,85)
Yellow: (255,255,0)
White: (255,255,255)
Cyan:
Black:
When you use a camera or a or a graphic tablet you create bitmap pictures.
Bitmap pictures come under different file extensions: BMP, GIF, JPEG, , TIFF.
The quality of a bitmap file is determined by its which tells you how many pixels the bitmap is made of. For instance a digital camera can have an resolution.
Pixel art graphics used in retro arcade games are a good example of bitmap pictures. You can create your own pixel art online using piskelapp.com
Vector Based Graphics
thickness
compressed
geometric shapes
processing
CAD drawings
grouped
pixelate
gallery
Vector Based graphics (also known as object-orientated graphics) are made up of many individual . Each of these shapes can be defined by mathematical/geometric statements and has individual properties assigned to it such as colour, fill, and size, , ...
All these geometric based data is saved in a vector based graphics as instructions such as: DrawLine Red, 1 pixel wide, 10 pixels long From position x=20 y=40
When editing a vector based graphics each object can be edited individually. Objects can also be to be moved/resized/rotated together.
Cliparts from the clipart tend to be vector based. are also vector based.
Vector based graphics do not loose quality or pixelate when they are resized as opposed to bitmap graphics which do or become blurry when they are enlarged or resized. Vector based cannot be as opposed to bitmap files which can be compressed (by loosing some quality)
Vector based files tend to take up less disk space than bitmaps. However Vector based graphics requires more power to be displayed on the screen.
Create your own vector graphics online using vecteezy.com
When programming a computer system, it is good practice to include a range of validation checks in the code to check if the data being inputted by the end-user follows some basic rules.
The aim of validation checks is to ensure that data used or stored by computer systems is valid. Invalid data may indeed make the system crash or may provide inaccurate information back to the user.
Validation checks cannot confirm if the data is correct or not but they can filter out a lot of invalid data.
There are different types of checks that can be implemented in your code such as:
Presence Check: When a field has to be filled in (mandatory field) and cannot be left blank/empty. (e.g username field when you sign in to a new system)
Length Check: When a field has to contain a set number of characters (e.g. a password is at least 8 characters long, a credit card number contains 16 digits).
Type Check: When a field has be of a certain data type (integer, float/real, etc.).
Range Check: When a field has be within a range, or greater or lower than given value. (e.g. A percentage value has to be between 0 and 100)
Lookup Check: When a field can only accept a certain set of values from a list (e.g. A title field can be either Mr, Mrs, Ms or Dr)
Character Check: When a field has to contain a specific character or type of characters. (e.g. An e-mail address should contain an “@” sign)
Vera Molnár (born 1924) is a French media artist of Hungarian origin. She is considered to be a pioneer of computer art. Trained as a traditional artist, she began working with computers in 1968, where she began to create algorithmic paintings based on simple geometric shapes and geometrical themes.
In this blog post we are looking at using Python Turtle to recreate some of her artwork. To create you own op art/computer art, you will need to be confident in using iterative algorithms and have a good understanding of Cartesian coordinates.
To find review some of Vera Molnár’s artwork you can use the following pages:
This is our first attempt at recreating some of Vera Molnár’s artwork using Python Turtle.
Artwork #2
This is our second attempt at recreating some of Vera Molnár’s artwork using Python Turtle.
Your Task
Your task is to select on other piece of artwork from Vera Molnár and write a computer algorithm using Python Turtle to recreate it. You can do so by adapting the scripts provided above.
In this challenge we will create a library of functions to apply the different formulas based on the geometry of triangles.
For each function, you will need to design the algorithm using either Pseudo-code or a flowchart, implement the function using the Python trinket provided below and use another algorithm to test your function.
PerimeterAreaAnglesEquilateralIsoscelesPythagoras' TheoremHeron's Formula
Write a function called getPerimeter() that takes three parameters/argumentsa, b, c (the length of each side of a triangle).
Your function should calculate and return the perimeter of this triangle.
Write an algorithm to test your function.
Your algorithm should:
Ask the user to enter the length of the 3 sides of a triangle,
Use the getPerimeter() function to retrieve the perimeter of the triangle,
Display the perimeter of the triangle
Write a function called getArea() that takes two parameters/arguments corresponding to the length of the base and of the height of a triangle.
Your function should calculate and return the area of this triangle.
Write an algorithm to test your function.
Your algorithm should:
Ask the user to enter the length of the base and height of a triangle,
Use the getArea() function to retrieve the area of the triangle,
Display the area of the triangle
Write a function called getAngle() that takes two parameters/arguments called angle1 and angle2 (the value of two angles in degrees)
Your function should calculate and return the value of the third angle: (180 – angle1 – angle2)
Write an algorithm to test your function.
Your algorithm should:
Ask the user to enter the value of two angles in degrees,
Use the getAngle() function to retrieve the value of the third angle,
Display this value on screen.
Write a function called isEquilateral() that takes three parametersa, b, c (the length of each side of a triangle).
Your function should workout if the triangle is equilateral (if all sides have the same length) and return a Boolean value (True or False) based on its finding.
Write an algorithm to test your function.
Your algorithm should:
Ask the user to enter the length of the 3 sides of a triangle,
Use the isEquilateral() function to find out if the triangle is an equilateral triangle,
Display a relevant message to the end user.
Write a function called isIsoscles() that takes three parametersa, b, c (the length of each side of a triangle).
Your function should workout if the triangle is an isosceles triangle (if any two sides have the same length) and return a Boolean value (True or False) based on its finding.
Write an algorithm to test your function.
Your algorithm should:
Ask the user to enter the length of the 3 sides of a triangle,
Use the isIsoscles() function to find out if the triangle is an isosceles triangle,
Display a relevant message to the end user.
Write a function called getHypotenuse() that takes two parameters/arguments called a and b (the length of two sides of a right-angled triangle).
Your function should calculate and return the length of the third side (the hypotenuse) of the triangle knowing that:
Write an algorithm to test your function. Your algorithm should:
Ask the user to enter the length of the 2 sides of a right-angled triangle,
Use the getyHypotenuse() function to retrieve the value of the hypotenuse of the right–angled triangle,
Display the value of the Hypotenuse.
Write a function called isRightAngledTriangle(), that takes three parameters a, b and c and works out if the triangle is a right-angled triangle or not. Your function should return a Boolean value (True or False) based on its finding.
Write an algorithm to test your function. Your algorithm should:
Ask the user to enter the length of the 3 sides of a triangle,
Use the isRightAngledTriangle() function to find out if the triangle is a right-angled trinagle,
Display a relevant message to the end-user.
Write a function called getTriangleArea() that takes three parameters/argumentsa, b, c (the length of each side of a triangle).
Your function will apply Heron’s formula to calculate and return the area of the triangle.
Write an algorithm to test your function.
Your algorithm should:
Ask the user to enter the length of the 3 sides of a triangle,
Use the getTriangleArea() function to retrieve the area of the triangle,
Display the area of the triangle
Python Code
We have already started the code for you and have completed the function getPerimeter() followed by a short algorithm to test this function.
Your task is to complete this Python script to create and test all the functions mentioned above.
Solution...
The solution for this challenge is available to full members! Find out how to become a member: ➤ Members' Area
The Heron’s formula is a famous formula used to calculate the area of a triangle based on the length of its three sides. It is called “Heron’s Formula” (sometimes called Hero’s formula) after Hero of Alexandria who was a Greek Engineer and Mathematician in 10 – 70 AD.
Python Task
Your task is to write a function called calculateTriangleArea(). Your function will:
Take three parameters corresponding to the length of the 3 sides of a triangle: a, b and c,
Apply Heron’s formula to calculate the area of the triangle,
Return the area of the triangle.
You will also then need to create a small program that will:
Ask the user to enter the length of the three sides of a triangle,
Calculate the area of the triangle using the calculateTriangleArea() function,
Output the area of the triangle.
Video Tutorial
Python Code
Test Plan:
Once your code is done, complete the following tests to check it is working as expected:
Test #
Input Values (in cm)
Expected Output (in cm2)
Pass/Fail?
#1
First side: 3 Second side: 4 Third side: 5
Area: 6
#2
First side: 8 Second side: 10 Third side: 12
Area: 39.686
#3
First side: 4 Second side: 8 Third side: 10
Area: 15.199
Extension Task #1
Create some extra functions to calculate the area of a square, of a rectangle and of a disc. Each function will need to accept the relevant parameters needed to calculate the area of the desired shape.
Extension Task #2
Create a menu system, where the user is asked what shapes they would like to calculate the area of before being asked to enter the relevant dimensions.
Did you know?
Illustration of Hero’s Aeolipile (Steam Engine)
Hero published a well-recognized description of a steam-powered device called an aeolipile (sometimes called a “Hero engine”). Among his most famous inventions was a windwheel, constituting the earliest instance of wind harnessing on land.
For this programming challenge we will investigate different functions which will all be based on a linear search algorithm.
Let’s consider a teacher who has decided to keep track of rewards issued to their students throughout the term by adding their name at the end of a text file each time they win a reward for their positive attitude and effort in lessons.
The teacher would like to write a few Python functions to:
scan the content of the text file and check if a particular students has received a reward or not,
count the number rewards a student has received throughout the term.
locate a student in the text file (identify the position/line number where the student’s name appear in the text file)
The teacher has started the code by creating a function called readTextFile() that takes a parameter called filename/ This function scan the context of the text file and return a list of all the names listed in the text file.
Using flowcharts, the teacher then worked out the algorithms for the extra functions they would like you to implement and test to complete the code. You can access these flowcharts below.
Is Listed?Rewards CountFind Position
The first function that you will need to implement is called isListed(), takes two parameters value and list and returns True if the value can be found in the list, false otherwise. To test this function you will need to implement the following algorithms:
Click on the above flowcharts to open in a new window
The third function is called count(), takes two parameters value and list and returns number of times the searched value appears in the list. To test this function you will need to implement the following algorithms used to count the number of rewards a student has received throughout the term.
Click on the above flowcharts to open in a new window
The second function to implement is called findPosition() takes two parameters value and list and returns the position (starting at position 1) of the value in the list or -1 if the item is not found. To test this function you will need to implement the following algorithms used to locate a name in the text file by identifying the line number where such name appears in the file.
Click on the above flowcharts to open in a new window
Python Code
You can now complete and test all three functions using the flowcharts provided above. The trinket below contains two tabs. In the second tab called “rewards.txt” you can access the content of the text file.
Alternative Approach
The Python syntax allows you to use loop through a list of values as follows:
for value in list:
print(value)
Not all programming languages will let you use this syntax. An alternative approach is to use indices:
for i in range(0,len(list)):
print(list[i])
In this case the flowchart for our count() function would become:
Solution...
The solution for this challenge is available to full members! Find out how to become a member: ➤ Members' Area
A leap year is a calendar year that contains an additional day (29th of February) added to keep the calendar year synchronised with the astronomical year or seasonal year (which contains roughly 365¼ days or 365.242375 days to be more accurate).
An easy way to work out if a year is a leap year or not is to check if the year (e.g. 2020) is a multiple of 4. If it is, then it is most likely a leap year. Indeed, the rule is slightly more complex than this and can be summarised in three statements:
Leap years are any year that can be exactly divided by 4 (such as 2004, 2008, 2012, 2016, 2020, 2024, etc)
except if it can be exactly divided by 100, then it isn’t a leap year (such as 2100, 2200, etc)
except if it can be exactly divided by 400, then it is a leap year (such as 2000, 2400, 2800, etc)
In Python to work out if a number is a multiple of 4, we can calculate the remainder (MOD) of dividing this number by 4. If this remainder is equal to zero, then the number is a multiple of 4.
Based on this we can create a small function that will take a number (year) as a parameter and return whether the given year is a leap year or not. Here is the flowchart for this function called isLeapYear():
We can then this function in any program where we need to work out if a year is a leap year or not. For instance, we can create a program that:
Asks the user to enter a year (e.g. 2020)
Check if the year entered is a leap year or not (using our isLeapYear() function!)
Outputs a message to inform the user if the year is a leap year or not.
Here is the flowchart for this program:
Video Tutorial
Your Task:
Use Python code to implement both the isLeapYear() function and the main program based on the above flowcharts.
Test Plan:
Once your code is done, complete the following tests to check it is working as expected:
Test #
Input Values
Expected Output
Pass/Fail?
#1
Year: 2020
2020 is a leap year. It contains 366 days.
#2
Year: 2021
2021 is not a leap year. It contains 365 days.
#3
Year: 2056
2056 is a leap year. It contains 366 days.
#4
Year: 2100
2100 is a not a leap year. It contains 365 days.
#5
Year: 2400
2400 is a leap year. It contains 366 days.
Solution...
The solution for this challenge is available to full members! Find out how to become a member: ➤ Members' Area
On July the 12th, a hundred prestigious guests were invited to the Precious Gemstones Exposition at the famous Royal Castle, England.
This exposition provides a unique opportunity to admire the most precious and valuable gemstones in the world.
The gemstones were exposed in the different rooms of the castle and were protected with a state-of-the-art security system.
At 10:12pm, a power cut left all the guests in the dark for a duration of just under five minutes. At the same time, the security system was deactivated.
When the power returned, the visitors were aghast to see that the twelve most precious gemstones of the exposition had simply vanished. The twelve gemstones were located in twelve different rooms. It would have been impossible for a single individual to steal more than one gemstone in such a short time. This means that this carefully planned robbery has been performed by a team of at least twelve robbers.
The guests have collected evidence left behind by the robbers and have asked you to use it to identify the potential robbers.
You have also been given access to a database of all staff members and guests who were present on that night.
Will you be able to identify the twelve robbers and confront them to retrieve the precious gemstones? To do so you will need to write and execute twelve different SQL queries using the set of clues listed below.. Here are some examples of SQL queries based on the suspects table:
SELECT * FROM suspects WHERE gender="Male" AND Nationality="Australia";
SELECT * FROM suspects WHERE firstname like "A%";
SELECT * FROM suspects WHERE gender="Male" AND (nationality="USA" OR nationality="Canada");
SELECT * FROM suspects WHERE height>=1.80 AND staff=TRUE;
The first gemstone is an intense red ruby which was exposed in the main lounge.
It would appear that the robber broke the glass case to grab the precious stone. They then broke the window and jumped outside.
Footprints have been found outside just below the broken window. The shoes are male shoes, size 10.5. They are not the type of shoes worn by the staff as part of their uniform. So the first robber must be one of the guests.
Can you use these clues to identify a potential culprit from the guests and staff list?
The second stone is the world largest blue sapphire. It was stolen from the dining room.
The robber seems to have hurt themselves when breaking the glass case protecting the gemstone. Some blood stains have been found on the carpet. A handkerchief has also been found with blood stains. It has most likely been inadvertently dropped by the robber who used it to clean their wound. On the handkerchief we can see two embroidered initials A.H.
Can you find anyone on the guests list with the initials A.H.?
This rare semi-translucent Onyx was exposed in the billiard room. A long blond hair has been found just next to the stand where the Onyx was displayed. The length of the hair suggests a female robber.
The back door of the billiard room was open. This door is equipped with a magnetic card/badge reader and can therefore only be opened by staff members from the security team.
This clear topaz was exposed in the centre of the ballroom. A candle from the main chandelier was found on the floor. This would suggest that, while leaving the room in the dark, the robber inadvertently hit the chandelier. This means that the robber must be at least 1.85m tall.
A wine glass was found next to the stand where the topaz was exposed. Red lipstick marks can be seen on the glass which would indicate a female robber.
The diamond was exposed in the library. A post-it note was found on the floor and one can assume it fell off the robber’s pocket or handbag. Some handwritten symbols appear on the post-it note but these are written using the Mandarin alphabet.
We can deduct that the robber may come from China, Taiwan or Singapore.
The tanzanite was exposed in the small lounge/tearoom.
On their way out of the room, the robber must have caught their jacket on the door hatch, ripping off a piece of the jacket and inside pocket. Inside this pocket, the guests found a torn piece of a business card where part of a name can be seen: “Mr Oli…” We can assume that the robber is a man and his first name or his last name starts with the letters “OLI”..
The jacket is not part of the staff uniform, so the robber must be a one of the guests.
The pink sapphire was exposed on the upstairs landing area. On their way out, the robber must have fallen down the stairs, as the guests reported hearing a loud noise. They also heard someone swear in English. The robber dropped their “Exposition information pack” which was given to all guests. In this pack an extra vegan menu page was found. This page is only given to guests with a vegan diet.
We can assume that the robber is either American (USA), Canadian, English or Australian and is also vegan.
The quartz was exposed in the kitchen.
A tray of Spanish tapas was presented on the kitchen table. The robber picked a few tapas with superior quality chorizo. This suggests that the robber is neither vegetarian nor vegan.
In the dustbin, an empty pack of disposable tissues was found. It had a price tag on it with a price of 8.5 kr (Danish Krones). This would indicate that the robber is most likely Danish.
The emerald was exposed in the study room. It would seem that the burglar had to force the window open to escape the room. An earring in the shape of the Eiffel Tower was found at the scene. It is believed to belong to a French female guest.
It is an expensive piece of jewellery and is unlikely that the staff members would wear such jewellery at work.
The amber was exposed in the main hall. A flower pot was knocked over during the robbery and the soil from the pot spread over the carpet. The robber walked over it and left a footprint on their way out. It appeared to be woman’s shoe with a size between 6 and 7.
The brand was also identified and is only sold in the following South American countries: Peru, Chile, Argentina, Brazil and Venezuela.
The peridot was exposed in the master bedroom. When the guests arrived at the scene, they could smell a subtle scent of jasmine, an essence used in women’s perfumes.
In the fireplace, some warm ashes of paper were found. However, the paper did not burn fully. It appears to be a plane ticket, indicating a flight leaving from Dublin Airport (Ireland). We would therefore assume that the robber might be a guest from Ireland.
The amethyst was exposed in the royal suite.
The royal suite has a slanted roof with wooden beams. It would appear that the robber bumped their head on one of these beams as blood was found. It would suggest the robber was between 1.70m and 1.80m tall. When this happened, the robber dropped their cap. It is a men’s cap worn by the gardening staff at the Royal Castle.
Solution...
The solution for this challenge is available to full members! Find out how to become a member: ➤ Members' Area