More results...

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

The Computer Shop – SQL Task

Working for an online computer shop, you have been asked to assist customers in finding the best computer deal to match their requirements and needs. Your shop has access to a large variety of laptop and desktop computers and hence you should be able to recommend a computer for every customer!

To make the right recommendation to your customers, you have been given access to an online database of all the computers available in stock. You can access and query this online database using our online SQL Editor:
Open in new windowAccess Online Database / SQL Editor

Your job is to:

  • Pick a customer and read through their requirements (see tabs below),
  • Write an SQL query to interrogate the database to identify the computer that meets their requirements,
  • Repeat this process for each customer.

Note that each one of your query should return one and only one computer that fully satisfies the customer’s demands.

Here are some examples of SQL queries based on the computers table:

SELECT * FROM computers WHERE type="Laptop" AND touchscreen=TRUE AND screenSize>=15;
SELECT * FROM computers WHERE type="Desktop" AND (HDD>1000 OR SSD>1000);
SELECT * FROM computers WHERE type="Laptop" AND RAM>=8 AND operatingSystem="Windows" AND (price>=300 AND price<=400);

Customer A:Customer B:Customer C:Customer D:Customer E:
Customer A is looking for a laptop computer to work on the train when commuting to work. They need a Windows laptop that is easy to carry around so would like a screen size of less than 16 inches. They would like the laptop to be touchscreen and would need an SSD drive of at least 512GB. They can spend up to £500 on this laptop.


SQL Query:

Recommended Computer:

Customer B is looking for a multimedia desktop computer to watch movies and stream music online. They would like a dual core or a quad core CPU with a clock speed of at least 2.5Ghz. They would like a HDD drive of at least 2TB (2000GB). They would like a large screen of at least 16 inches.


SQL Query:

Recommended Computer:

Customer C is a graphic designer who would like a desktop computer to use graphic editing and photo-editing software. They are looking for a MacOS desktop computer with a touchscreen of 17 inches. They would need an SSD drive of at least 256GB and a secondary hard drive to backup their work with at least 1TB (1000GB). They are happy to spend up to £600 on their computer.


SQL Query:

Recommended Computer:

Customer D is a student who needs a laptop to take notes during lectures. They have a small budget (up to £350) and would like a computer with at 6GB or 8GB of RAM, a screen size between 14 to 16 inches, a secondary drive either HDD or SSD of at least 512GB and the Windows operating system already installed.


SQL Query:

Recommended Computer:

Customer E is looking for a laptop to be used by his family around the house. They would prefer it to be a dual core laptop with at least 8GB of RAM. They would like a touchscreen of 15.6 inches and an SSD drive of either 256GB or 512GB.


SQL Query:

Recommended Computer:

Extension Tasks:

Warning: When completing the following extension tasks, note that, on this online system, Boolean values are actually stored as string containing the values “TRUE” and “FALSE”. This means that, in your queries, you will need to use “speechmarks” when storing the values “TRUE” and “FALSE” as string instead of Boolean values.

Price ListNew Computer in StockDiscount on Windows LaptopsDiscontinued Range
The shop manager would like you to produce a price list, only listing the name, type, operating system and price of all the Laptops in stock, in descending order of price (from the most expensive computer to the cheapest computer).

SQL Query:

A new computer has been delivered to the shop and needs to be added to the database. Run a query to add this computer to the computers table. The characteristics of this new computer are as follows:

Name Notebook NB-450
Type Laptop
Number of Cores 4 (Quad Core)
Clock Speed 3.5GHz
RAM 16GB
Hard Disk Drive 1TB
Solid State Drive 256GB
Screen Size 16
Touchscreen
Operating System MacOS
Price £550

Warning: In this computers table the ID field is not set as an AUTO_INCREMENT field. Which means that you will have to provide a value for the ID field within your INSERT query.

SQL Query:

The shop would like to apply a 20% discount on all Windows laptops. Use a query to update the reduce the price of all windows laptops by 20%.

SQL Query:

The shop has decided to stop selling computers from the “Smartpad” series and from the “Smartbook” series. Use a query to remove all the computers from the computers table where the name of the computer starts with either “Smartpad” or “Smartbook”.

SQL Query:

unlock-access

Solution...

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

The Bike Shop – SQL Task

As a newly appointed shop assistant for your local bike shop, you have been asked to help customers find their dream bike: a bike that meets all of their requirements. Your shop has access to a large variety of mountain bikes, road bikes and hybrid bikes and hence you should be able to find a bike for every customer!

Each of these bikes has its own specifications such as frame type (crossbar or low-edge frame), frame size (from XS to XL), wheels size, number of gears and so on.

To assist you in helping find the perfect bikes for your customers, you have been given access to an online database of all the bikes available in stock. You can access and query this online database using our online SQL Editor:
Open in new windowAccess Online Database / SQL Editor

Your job is to:

  • Pick a customer and read through their requirements (see tabs below),
  • Write an SQL query to interrogate the database to identify the bike that meets their requirements,
  • Repeat this process for each customer.

Note that each one of your query should return one and only one bike that fully satisfies the customer’s demands.

Here are some examples of SQL queries based on the bikes table:

SELECT * FROM bikes WHERE type="Mountain Bike" AND frame_size="L" AND electric=TRUE AND weight<10;
SELECT * FROM bikes WHERE type="Hybrid Bike" AND (frame_size="L" OR frame_size="XL") AND Hydraulic_Brakes=True;
SELECT * FROM bikes WHERE type="Road Bike" AND (price>=300 AND price<=500);

Customer A: Milly SpokeCustomer B: Tim SaddleCustomer C: Ayaz BearingCustomer D: Nikky HelmetCustomer E: Fred TyreCustomer F: Hamza ChainstayCustomer G: Joe CrossbarCustomer H: Lin DynamoCustomer I: Marek HubcapCustomer J: Anna Fork
Milly Spoke is looking for a hybrid bike to commute every day to her college. She would like a bike in the price range of £150 to £250. Ideally her bike should not be too heavy so she is looking at a bike of less than 15kg. Based on her height, she was recommended to consider an M frame size. She is not too fussy about technical characteristics such as number of gears or types of brakes!


SQL Query:

Recommended Bike:

Tim Saddle is a keen cyclist and would like to improve his performance when taking part in bike races. He is very specific in his requirements and is looking for a state of the art road bike with at least 27 gears, hydraulic brakes, disc brakes with a very light frame (<8 kg), 20 inches wheels and a large frame size (L). He has no limits on how much he can spend for this bike!


SQL Query:

Recommended Bike:

Ayaz Bearing is looking for an electric Mountain Bike to go mountain biking during the holidays. He would like a Crossbar frame with at least 21 gears. He is not too sure about the size so would like to find out if you have any bike in stock with either an L frame or XL frame.


SQL Query:

Recommended Bike:

Nikky Helmet is looking for either a mountain bike or hybrid bike to go through cycling paths in the forest. She is looking for an L frame, low-step frame and would like the bike to be fitted with hydraulic brakes.


SQL Query:

Recommended Bike:

Fred Tyre works in the city and is commuting to work everyday by bike. He is looking for a hybrid e-bike (electric). He needs an M frame with hydraulic disc brakes and has a budget of £500 to £700.


SQL Query:

Recommended Bike:

Hamza Chainstay is looking for a road bike, with a crossbar frame size M and wheels of 24, 26 or 27 inches. He would like the bike to weight no more than 12kg.


SQL Query:

Recommended Bike:

Joe Crossbar is looking for a mountain bike, with a crossbar frame size M or L. He would like hydraulic brakes but does not want the bike to be fitted with disc brakes. He is not interested in electric bikes.


SQL Query:

Recommended Bike:

Lin Dynamo is looking for an electric hybrid bike to commute to work every day. She would like a low-step frame but is not too sure of the size she needs. She would like to see if you have either an S or an M frame in stock. She would also like to spend less than £600 on her bike.


SQL Query:

Recommended Bike:

Marek Hubcap would like a road bike within a budget of £200 to £300 and at least 24 gears. He would like to have disc brakes and a light frame e.g. less than 10 kg.


SQL Query:

Recommended Bike:

Anna Fork would like a non-electric mountain bike, frame M with 21 or 24 gears, hydraulic and disc brakes. She has a budget of £300 to £400 for this bike.


SQL Query:

Recommended Bike:

Extension Tasks:

Warning: When completing the following extension tasks, note that, on this online system, Boolean values are actually stored as string containing the values “TRUE” and “FALSE”. This means that, in your queries, you will need to use “speechmarks” when storing the values “TRUE” and “FALSE” as string instead of Boolean values.

Price ListNew Bike in StockDiscount on Electric BikesDiscontinued Range
The shop manager would like you to produce a price list, only listing the name, type, frame size and price of all the Mountain bikes in stock, in descending order of price (from the most expensive bike to the cheapest bike).

SQL Query:

A new bike has been delivered to the shop and needs to be added to the database. Run a query to add this bike to the bikes table. The characteristics of this new bike are as follows:

Name Urban Explorer X-200
Type Hybrid
Frame Type Crossbar
Electric
Frame Size M
Wheel Size 24 inches
Gears 21
Weight 14.2Kg
Hydraulic Brakes
Disc Brakes
Price £650

Warning: In this “bikes” table the ID field is not set as an AUTO_INCREMENT field. Which means that you will have to provide a value for the ID field within your INSERT query.

SQL Query:

The shop would like to apply a 10% discount on all electric bikes. Use a query to update the reduce the price of all electric bikes by 10%.

SQL Query:

The shop has decided to stop selling bikes from the “Road Rider” series. Use a query to remove all the bikes from the bikes table where the name of the bike starts with “Road Rider”.

SQL Query:

unlock-access

Solution...

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

Drawing flags using Python Turtle

In this challenge we will use Python Turtle to draw a range of flags on screen.

First, you will need to investigate the code used to create three different flags:

France Sweden Czech Republic

To understand these code snippets you need to understand how to position the turtle (pen) on the screen using (x,y) coordinates. The following two templates will help you understand coordinates and be useful to help you design the algorithm to draw your own flags.

Python Code

Here is the code for our first three flags.

FranceSwedenCzech Republic

France

Sweden

Czech Republic

Your Turn

You can edit the trinkets above to recreate your own selection of flags. Here are some flags you could try to reproduce:

Chad

Luxembourg

Columbia

Iceland

Jamaica

Ghana

Turkey

Tanzania

Cuba

Tagged with:

Boolean Algebra using Logic Gates

Boolean Algebra is used to simplify long/complex Boolean expressions. It is needed to optimise the use of logics gates (and hence transistors) when making an electronic circuit. Considering that the CPU is made of billions of logic gates, it is essential to find the optimal logic gates circuits to solve a given problem.

There are a few Boolean Algebra rules that are used to simplify Boolean expressions. In this challenge, you will recreate some logic gates circuits to verify some of these rules.

You can also investigate these rules further by simplifying Boolean expressions on this challenge.

The first few circuits have already been completed and your task is to create more logic gates circuits to verify the following rules.

Double NegationComplement LawsAssociative LawsDistributive LawsAbsorptive LawsDe Morgan's Rules

Double Negation

¬ ¬A = A

Logic Gates Circuit


Click on the above circuit to test it online

Complement Laws

A ∧ ¬A = 0
A ∨ ¬A = 1

Logic Gates Circuit


Click on the above circuit to test it online

Click on the above circuit to test it online

Associative Laws

(A ∧ B) ∧ C = A ∧ (B ∧ C)
(A ∨ B) ∨ C = A ∨ (B ∨ C)

Logic Gates Circuit


Click on the above circuit to test it online

Click on the above circuit to test it online

Distributive Laws

A ∧ (B ∨ C) = (A ∧ B) ∨ (A ∧ C)
A ∨ (B ∧ C) = (A ∨ B) ∧ (A ∨ C)

Logic Gates Circuit


Click on this picture to create a logic gates circuit to verify these rules

Absorptive Laws

A ∧ (A ∨ B) = A
A ∨ (A ∧ B) = A

Logic Gates Circuit


Click on this picture to create a logic gates circuit to verify these rules

De Morgan’s Rules

¬(A ∨ B) = ¬A ∧ ¬B
¬(A ∧ B) = ¬A ∨ ¬B

Logic Gates Circuit


Click on this picture to create a logic gates circuit to verify these rules

Tagged with:

Logic Gates Challenges

For this set of challenges, your task is to design logic gates circuits in order to produce the desired output for the given inputs as described in each challenge. You can combine as many logic gates as necessary using the standard logic gates (NOT, AND, OR, XOR, etc.)

Challenge #1Challenge #2Challenge #3Challenge #4Challenge #5

Challenge #1

The light bulb should only be on when either:

  • Both inputs A and B are on while input C is off

or:

  • Both inputs A and B are off while input C is on

Click on this picture to create a logic gates circuit to solve this challenge

Challenge #2

The light bulb should be one when only one of the inputs is on while the remaining two inputs are off.

Click on this picture to create a logic gates circuit to solve this challenge

Challenge #3

The light bulb should be one when any two of the inputs are on while the remaining input is off.

Click on this picture to create a logic gates circuit to solve this challenge

Challenge #4

  • When input A is on, the light bulb should be controlled by turning switch B on and off.
  • When input A is off, the light bulb should be controlled by turning switch C on and off.

Click on this picture to create a logic gates circuit to solve this challenge

Challenge #5

This challenge will require 4 inputs: A, B, C and D.
The light bulb should only be on when either:

  • Both inputs A and D are on while B and C are off

or:

  • Both inputs A and D are off while B and C are on

Click on this picture to create a logic gates circuit to solve this challenge

unlock-access

Solution...

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

Digital Padlock using Logic Gates

In this post we are going to use logic gates and D-Type Flip-Flop circuits to create a 3-bit digital padlock with a stored combination that can be reset.

Let’s first investigate how we are going to store the 3-bit combination in our circuit using 3 D-Type Flip-Flop circuits.

D-Type Flip-Flop Circuits


A D-Type Flip-Flop circuit is a circuit used to create a memory cell to store 1 bit of information (0 or 1). It is built using four NAND logic gates connected as follows:
D-Type-Flip-Flop-Logic-Gates

We represent a D-Type Flip-Flop Circuit as follows. You can change the input values D and E by clicking on the corresponding buttons below to see the impact on the outputs Q and Q.




D-Type-Flip-Flop-Circuit




You can also test the behaviour of a D-Type flip-flop circuit using our online simulator:
Click on the above circuit to open in a new window.

A D-Type Flip-Flop Circuit is used to store 1 bit of information. It has two input pins (Called D (Data) and E (Enabler) and two output pins (Q and Q = NOT Q).

The truth table of a D-Type Flip-Flop circuit is as follows:
D-Type-Flip-Flop-Truth-Table

When the enabler input E is set to 1, the output Q can be set to the Data input D.
When the enabler input E is set to 0, the output Q cannot be changed. It remains as its previous value. In other word it retains its value. This is why this circuit is used to create memory cells (e.g in the RAM).

Random Access Memory (RAM) consists of billions of data cells, each data-cell uses a D-Type flip-flop circuit.

Random Access Memory (RAM) consists of billions of data cells, each data-cell uses a D-Type flip-flop circuit.

Digital Padlock

To create our padlock we will need a circuit to input a 3-bit combination and store it using 3 memory cells (D-Type Flip-Flop circuits).

We will then use another set of 3 inputs to let the user try to unlock the padlock by trying different combinations. You can click on the circuit below to access our full 3-bit digital padlock.

You will notice on this circuit that the 3 XNOR gates are used to compare each digit (user guess with combination). If both digits are the same (both set to 0 or both set to 1) the XNOR gate output is on. The AND gates are then used to check if all 3 digits have been guessed right. In this case the lightbulb will turn on, indicating that the user has found the correct combination/key.

To use this circuit you will need to complete the following 5 steps:

  1. Input a combination (e.g. 101) using the top 3 switches set to “On-Off-On”.
  2. Turn the enabler (Reset button) to “on” to store this combination into the memory cells.
  3. Turn the enabler (Reset button) to “off” to lock the combination.
  4. Hide the combination by turning all top 3 switches to “off”.
  5. Use the bottom 3 switches to try to guess the right combination. The bulb should only be on when the right combination is inputted (e.g. 101).

Your task

First you will need to test the above circuit with different combinations to see if it works. Then your task is to complete this circuit by adding an extra digit to the key and turn this padlock into a 4-bit padlock.

unlock-access

Solution...

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

Design your own Logic Gates Circuits

In this blog post your will use our logic gates circuits simulator to create and test your own circuits.

Circuit #1

Our first circuit will be based on the following Boolean Expression:

Click on the above circuit to open it in our Logic Gates Circuits simulator.

This is now your turn to recreate some logic gates circuits using the following Boolean expressions.

Circuit #2

Use the logic gates circuits simulator to create and test a circuit based on the following Boolean expression:

Circuit #3

Use the logic gates circuits simulator to create and test a circuit based on the following Boolean expression:

Circuit #4

Use the logic gates circuits simulator to create and test a circuit based on the following Boolean expression:

Circuit #5

Use the logic gates circuits simulator to create and test a circuit based on the following Boolean expression:

Circuit #6

Use the logic gates circuits simulator to create and test a circuit based on the following Boolean expression:

unlock-access

Solution...

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

GCSE Computer Science Revision

Getting ready for your GCSE Computer Science exams? Test our knowledge by answering all the following questions:
GCSE Computer Science RevisionOpen in New Window

Daily Protocolometer

In this post, we are investigating our daily use of the main protocols used when accessing the Internet while using our smartphone, laptop or desktop computer, tablet, smartTV or game console.

Protocols are an essential concept to enable network communications and data transfer between different devices. A protocol defines the rules to be followed by both devices to be able to communicate with one another.

On the Internet, most communications use the TCP/IP range of protocols which relies on packet switching and the use of IP addresses to uniquely identify devices on the network.

Protocols can also be grouped into layers: The TCP Stack consists of 4 key layers:

  • The application layer which regroups the following protocols: HTTP, HTTPS, FTP, SMTP, POP3, IMAP, etc.
  • The transport layer which consists mainly of the TCP and UDP protocols
  • The internet layer which consists mainly of the IP Protocols (e.g. IPv4, IPv6)
  • The link layer (a.k.a. physical layer) which regroups various protocols used to transfer data over a cable (e.g. Ethernet protocol) or wirelessly (e.g. WiFi, 3G/4G/5G) protocols.

Your Task

Answer the following 10 questions to evaluate your daily use of networking protocols:

Daily ProtocolometerOpen in New Window

Hair & Beauty Salon – Entity Relationship Diagram (ERD)

“Stylish” is a Hair & Beauty Salon offering a wide range of hair & beauty treatments to customers. They currently employ five hair stylists and three beauticians. They currently use a notebook to record all their information such as customer contact details, appointments, treatments to be performed and payments.

They would like a new IT system to optimise their booking systems and keep track of payments so that they can renumerate their employees accordingly based on the treatments they completed.

They would like the new system to allow staff to:

  • Record customers’ contact details, so that existing customers do not have to provide their details every time they book an appointment.
  • Record dates and times of appointments and for each appointment, record the list of services/treatments being booked and for each treatment record the name of the employee who will be performing the treatment.
  • Calculate and store the total cost of the treatments booked and store this information with the appointment details alongside a status field to indicate whether the appointment has been paid or not.

Your task is to review the requirements of this Hair & Beauty Salon in order to design the Entity Relationship Diagram (ERD) for this system.

For more information about relational databases and Entity Relationship Diagrams, visit the following pages:

Use our online ERD tool to design the Entity Relationship Diagram for this salon. Note that you have not been given all pieces of information to store about the employees, customers, appointments, bookings, treatments and payments so you will have to decide of the most relevant fields to include on your ERD.

Design Your ERD Online
unlock-access

Solution...

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