Storage Devices Python Challenge

The aim of this challenge is to create an “Odd One Out” quiz on storage devices using Python. But let’s first revisit the main technologies used by storage devices in a computer system.

We can categorise all the storage devices found within a computer system into three main categories based on the technology they rely on to store binary data:

Magnetic Storage Devices


Magnetic storage devices such as magnetic tapes, floppy disks, and hard disk drives (HDD). A hard drive contains a spinning disk coated with a magnetic material. A read/write head moves over the disk, changing the magnetic properties to store data. Magnetic tapes work similarly, but data is stored in a linear format on a magnetic ribbon (tape).

Optical Storage Devices


Optical storage devices such as CDs, DVDs and Blu-ray disks. With this technology, data is stored on the disc as tiny pits (dents) and lands (flat areas). A laser shines onto the surface, and the reflection is interpreted as binary data (1s and 0s) by a computer.

Flash/Solid State Storage Devices


Flash (a.k.a. solid state) storage devices such as USB Keys, SD cards, Micro-SD cards and Solid Sate Drives (SSD). Data is stored in memory chips that can be accessed almost instantly. These chips are made of semiconductors, which can retain data even when the device is powered off.

Python Quiz

For the purpose of this quiz we have stored the information regarding the different storage devices used in a computer system and their technology using three lists in Python:

optical = ["CD","DVD","Blu-ray"]
magnetic = ["Magnetic Tape","Floppy Disk","Hard Disk Drive (HDD)"]
flash = ["USB Key","SD Card","Micro-SD Card","Solid State Drive (SSD)"]

Using Python, you can easily merge two or more lists together using the + operator. e.g. to create a list containing all the storage devices:

allDevices = optical + magnetic + flash

Using the random library you can use two key functions shuffle() and choice():

import random

# Shuffle all the values of a list:
random.shuffle(allDevices)
print(allDevices)

# Pick a random value from a list:
randomDevice = random.choice(allDevices)
print(randomDevice)

Odd One Out Quiz

Your task is to create a 10-question quiz where for each question, the computer will randomly pick 2 storage devices of the same technology (e.g. two optical devices) and one random device from a different technology (e.g. either magnetic or flash). The computer will then display these three devices in a random order and ask the user to identify which of the three device is the odd one out.

For each correct answer the user should score 1 point. At the end of the 10 questions, the user should see their score out of 10.

Python Code

To complete this Python challenge you will need to complete the code below:

unlock-access

Solution...

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

Did you like this challenge?

Click on a star to rate it!

Average rating 4.4 / 5. Vote count: 59

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!