Lesson activities for



Download 363.63 Kb.
Page2/5
Date28.01.2017
Size363.63 Kb.
#9623
1   2   3   4   5

Lesson 2 activities

Activity 2.1

Use the image you encoded for your homework to complete these calculations.



How many bytes are required to represent the uncompressed file?

Remember: number of squares in grid x 2 / 8




How many bytes are required to represent the RLE encoded file?

Remember: number of codes x number of bits in each code / 8




How much storage space have you saved?




Extension

Imagine that an image:

  • contains 1,024 pixels (a grid of 32 pixels by 32 pixels)

  • contains 255 different colours (represented by 8 bits)

The image has been encoded using RLE, producing 116 binary codes comprising 8 bits (to represent the 255 colours) and 5 bits (to represent the colour run length).

Using this information, calculate:

How many bytes are required to represent the uncompressed file?




How many bytes are required to represent the RLE encoded file?




How much storage space have you saved?





Activity 2.2

Use the Run Length Encoding Calculator to encode these text strings.

Text string

Answer

AAAABBBBBBBBBCADDDDEEFFFFFFFF




ABCABCABCABCABCABCABCABCABCS




BBGGYYAACCFFEEBBGGYYAACCFFEE







Which one compresses the most?




Why is this?




Describe in English the process the RLE calculator follows to encode a piece of text.





Activity 2.3

An RLE compression algorithm works by removing repeated data and replacing it with a number representing the run length of that item.



  • Fill in the gaps to complete this algorithm.

1. Start with the first character in the string.

2. Write down the number 1.

3. Compare the first character with the next character on the right.

4. If they are the same, ___________________________________.

5. If they are not the same, ________________________________.

6. Move on to the next character on the right.

7. Go back to step 2 and repeat until you reach the end of the string.

8. _____________________________________________________.



  • Test out the algorithm using these data strings:

  • AAAABBBBBBBBBCADDDDEEFFFFFFFF

  • ABCABCABCABCABCABCABCABCABCS

  • BBGGYYAACCFFEEBBGGYYAACCFFEE


Activity 2.4 (homework)

Write a program in Python to implement the RLE compression algorithm you completed in Activity 2.3.



Activity 2.5 (extension)

Write a program in Python to decode a file compressed using RLE compression.



Lesson 3 activities

Activity 3.1

The wheels on the bus go round and round, round and round, round and round.

The wheels on the bus go round and round all day long.




How many characters, including spaces and punctuation marks, are there in this song?




Assuming one byte is used to represent each character, what is its file size?







Complete this table.

Word

Number of times used

Number of bytes in word

The

2

3

wheels

2

6

on

2

2

the

2

3

bus







go







round







and







all







day







long







Activity 3.2

  • Complete this lookup table of all the words used more than once in the song.

    Lookup table

    0.

    The

    1.

    wheels

    2.

    on

    3.

    the

    4.




    5.




    6.




    7.




  • Use the lookup table you have completed to encode the song, replacing repeated words with the number representing their position in the table.




Activity 3.3

A lookup table has been used to encode this text:



Encoded text

0 1 2 3 generally more effective than 4 1 2 in reducing 5 size 6 7. However, whereas 4 2 allows 5 8 1 9 10 perfectly reconstructed from 5 compressed 1, 11 2 causes some 6 5 8 1 9 10 permanently lost.

0 1 2 3 most often 12 for media 7, i.e. music, pictures 13 videos. This type 6 1 3 intended 9 10 12 14 humans whose brains are capable 6 ‘filling in 5 gaps’ created 14 11 2.

MP3 uses 11 1 2 9 compress audio 7 for use on portable media players where space 3 limited.

PNG 13 GIF use 4 1 2 9 reduce 5 size 6 image 7.





0.

Lossy

1.

data

2.

compression

3.

is

4.

lossless

5.

the

6.

of

7.

files

8.

original

9.

to

10.

be

11.

lossy

12.

used

13.

and

14.

by



Decode the text.




Short and Sweet’

Complete the worksheet activity ‘Short and Sweet’ from Computer Science Unplugged.



Extra for Real Experts’

Complete the worksheet activity ‘Extra for Real Experts’ from Computer Science Unplugged.Lesson 4 activities



Activity 4.1

Use an image editor, such as pixlr’s photo editor online, to experiment with compression. Start with an uncompressed BMP file. Fill in this table.



Original BMP image

JPEG with 100% quality

[Insert image here]


[Insert image here]

File size:

File size:

Image quality:


Image quality:


JPEG with 50% quality

JPEG with 25% quality

[Insert image here]


[Insert image here]

File size:

File size:

Image quality:


Image quality:


Activity 4.2

Use a media player such as iTunes to experiment with music compression by encoding a music file using different bit rates.



Original uncompressed WAV file

Higher quality MP3
(around 192kbps)


[Insert sound file here]


[Insert sound file here]

Sound quality:

Number of kbps:

Number of kbps:

File size:


File size:

High quality MP3
(around 160kbps)


Good quality MP3
(around 128kbps)


[Insert sound file here]


[Insert sound file here]

Number of kbps:

Number of kbps:

File size:


File size:

Activity 4.3

Lossless and lossy compression summary sheet


Explain what is meant by lossless compression.



What type of data can be compressed using a lossless compression algorithm?



Describe how a lossless RLE algorithm works.



Some lossless compression algorithms use a lookup table. Explain what the lookup table is for.



Explain how lossy compression differs from lossless compression.



Explain why lossy compression is usually used for media files.



Outline the process of compressing an audio file using a lossy compression algorithm.



Outline the process of compressing a bitmap image using a lossy compression algorithm.



Lesson 5 activities

Activity 5.1

Crack this code!

WKH WUHDVXUH LV KLGGHQ XQGHU WKH SDOP WUHH





Hint: H = E and W = T

Activity 5.2

Who uses encryption and what do they use it for what?

Users of encryption

What they use encryption for

Businesses




Individuals




Governments




E-traders




The military




Activity 5.3 (homework)

Create your own cipher and then use it to encrypt a secret message. Make sure you keep a note of the key to cracking your cipher, so that you (or someone else) can decode the message later!


Lesson 6 activities

Activity 6.1

Use a Caesar cipher to decode and encode these messages.

Plain text

Shift

Encrypted text

THE ENIGMA MACHINE WAS INVENTED BY THE GERMANS

+3




COLOSSUS WAS THE WORLD’S FIRST DIGITAL COMPUTER

+4







+5

YMJ HFJXFW HNUMJW NX FS JCFRUQJ TK WTRFS NSLJSZNYD




-3

QEB HBV FP EFAABK RKABO QEB CILTBO MLQ

Activity 6.2

With a partner, produce a step-by-step guide to using a Caesar cipher to produce an encoded message.



Activity 6.3 (homework)

Produce a step-by-step guide to decrypting messages that have been encoded using a Caesar cipher.


Lesson 7 activities

Activity 7.1

A function caesar_cipher_encrypt has two arguments: a string ‘message’ and an integer ‘key’ and returns a string ‘encrypted_message’.

All the characters that can be encrypted are stored in a list ‘letters’. Any characters in ‘message’ that are not in list ‘letters’ cannot be encrypted.


  • Load and run the function to see for yourself what it does. First, open Activity7.1.py in IDLE, then click Run > Run Module. Once the Python shell has loaded remember that to run the function you need to call it and enter its arguments.

  • Try different messages and different keys. What happens when a message includes a character that can’t be encrypted? What happens when the character to be encrypted is a ‘z’?

  • Add comments to the Python code to explain how it works. You should add a comment after every # in the Python code.

  • Amend the function so that the digits 1–9 can also be encrypted.

Activity 7.2

  • In pairs, make a new version of the function called caesar_cipher_decrypt that decrypts text encrypted using a Caesar cipher.

  • Add comments to the Python code to explain how this function differs from the original.

Hint: The inputs to the function should be the text to be decrypted and the shift to be applied.

Hint: The function should return the decrypted message.

Activity 7.3

There is really no need to have separate functions to encrypt and decrypt messages. Produce a new function caesar_cipher that does both.

Hint: The function will need a third argument: a string ‘action’ to determine whether the message has to be encrypted or decrypted.

Activity 7.4

Write a user interface for the caesar_cipher you produced in Activity 7.3. It should ask the user to select whether they want to encrypt a message, decrypt a message or exit the program.


Lesson 9 activities

Activity 9.1

List as many different types of digital computers as you can. Look for computers both in the past as well as the present, and for objects that contain embedded computers.































































Activity 9.2

Sort the things in this list according to whether they are hardware or software.

  • Mouse

  • Computer program

  • Web browser

  • Microphone

  • CPU

  • Hard disk drive

  • Digital camera

  • Windows operating system

  • DVD drive

  • Touch screen

  • Word processor

  • Speakers

  • Spreadsheet

  • Printer

  • Mobile phone app

  • Android operating system

  • SD memory card



Hardware

Software





























































Activity 9.3 (homework)

Answer these questions to summarise what you have learned in this lesson.

What is a digital computer?




Define computer hardware.




Give an example of computer hardware.




Define computer software.




Give an example of computer software.





Download 363.63 Kb.

Share with your friends:
1   2   3   4   5




The database is protected by copyright ©ininet.org 2024
send message

    Main page