{"base":{"id":"cs10-06","subject":"Data representation","title":"Text, images and sound as numbers","scene":"bin10","steps":[{"mode":"ascii","eyebrow":"Text","title":"Every character is a number","body":"A character set gives every letter, digit and symbol a number code. In ASCII, A is 65 and a is 97. Slide through the codes and find how capitals and small letters are linked.","controls":[{"id":"c","label":"Character code","min":32,"max":126,"step":1,"value":65}]},{"mode":"word","eyebrow":"Words","title":"Text is a list of codes","body":"A word is stored as one code per character, including spaces and punctuation. In ASCII each character uses one byte. Tap each word and count its bytes.","actions":[{"id":"w0","label":"Hi!"},{"id":"w1","label":"CAT"},{"id":"w2","label":"Ava 14"}]},{"mode":"bitmap","eyebrow":"Images","title":"Pixels and colour depth","body":"A bitmap image is a grid of pixels. Each pixel stores a binary code for its colour. The number of bits per pixel is the colour depth. Raise it and watch the colours appear.","controls":[{"id":"depth","label":"Colour depth (bits)","min":1,"max":3,"step":1,"value":2}]},{"mode":"resolution","eyebrow":"Resolution","title":"More pixels, more detail","body":"Resolution is how many pixels make up the image. More pixels give smoother curves but a bigger file. Slide from a blocky 4 × 4 sun to a smooth one.","controls":[{"id":"res","label":"Pixels across","min":4,"max":48,"step":4,"value":8}]},{"mode":"sound","eyebrow":"Sound","title":"Measuring a wave","body":"Sound is a smooth wave. A computer measures its height many times a second (the sample rate) and stores each measurement as a binary number (the sample resolution). Improve both.","controls":[{"id":"rate","label":"Sample rate","min":2,"max":16,"step":1,"value":8},{"id":"depth","label":"Sample resolution (bits)","min":2,"max":6,"step":1,"value":3}]},{"mode":"quiz","look":"bitmap","eyebrow":"Check yourself","title":"Colour depth","body":"An image uses a colour depth of 4 bits per pixel.","question":"How many different colours can it show?","options":["4","8","16"],"answer":2,"right":"Correct. 4 bits give 2⁴ = 16 different codes, one per colour.","wrong":"Not quite. n bits give 2ⁿ different patterns."}],"more":[{"type":"cards","id":"worked","eyebrow":"Worked examples","title":"Step by step","intro":"Every media type is just numbers. The only questions are how many numbers and how many bits each.","items":[{"tag":"Text","title":"How many bits for \"Hello world\" in ASCII?","body":"count characters (the space counts!): 11\n11 × 8 bits = 88 bits = 11 bytes","code":true},{"tag":"Image","title":"A 20 × 10 image with 256 colours","body":"256 colours = 2⁸ → 8 bits per pixel\npixels: 20 × 10 = 200\nsize: 200 × 8 = 1600 bits = 200 bytes","code":true},{"tag":"Sound","title":"10 s of mono sound, 8 000 samples/s, 16-bit","body":"samples: 8 000 × 10 = 80 000\nbits: 80 000 × 16 = 1 280 000\nbytes: ÷ 8 = 160 000 B ≈ 156 KiB","code":true},{"tag":"Python","title":"Characters and codes in code","body":"ord(\"A\")   # 65\nchr(97)    # 'a'\n\"A\".lower() # 'a'\nfor ch in \"Hi\":\n    print(ch, ord(ch))","code":true}]},{"type":"cards","id":"mistakes","eyebrow":"Common mistakes","title":"Watch out for these","items":[{"tag":"Mistake","title":"Forgetting spaces and punctuation","body":"\"Hi Leo!\" is 7 characters, not 5. Every space and symbol has its own code."},{"tag":"Mistake","title":"\"8 colours need 8 bits\"","body":"8 colours need only 3 bits (2³ = 8). Find the power of 2, not the number itself."},{"tag":"Mistake","title":"Mixing up resolution and colour depth","body":"Resolution = how many pixels. Colour depth = how many bits per pixel. Both change the file size."},{"tag":"Mistake","title":"\"Higher sample rate = louder\"","body":"Sample rate affects how accurately the sound is copied, not its volume. Volume is the height of the wave."}]},{"type":"cards","id":"method","eyebrow":"Set out your answer","title":"Explaining effects on quality and size","items":[{"tag":"Images","title":"Two effects, every time","body":"\"Increasing the resolution means more pixels, so more detail, but the file size increases.\" Always give the effect on quality AND on size."},{"tag":"Sound","title":"Name the two settings","body":"Sample rate: samples per second (in hertz). Sample resolution: bits per sample. Higher values give a more accurate recording and a bigger file."},{"tag":"Text","title":"Character sets","body":"\"ASCII uses 7 bits (often stored in 8) and covers English. Unicode uses up to 32 bits so it can represent every language and emoji, but takes more space.\""}]},{"type":"bars","id":"sets","eyebrow":"Data","title":"Character sets compared","intro":"How many characters each one can represent:","items":[{"label":"ASCII (7-bit)","value":10,"display":"128 characters","color":"#2f6fdb"},{"label":"Extended ASCII (8-bit)","value":18,"display":"256 characters","color":"#0e9aa7"},{"label":"Unicode (in use, 2025)","value":100,"display":"about 155 000 characters","color":"#db2777"}],"facts":[{"title":"Emoji are Unicode too","body":"😀 is U+1F600: code number 128 512. When someone's phone shows a box instead of an emoji, it doesn't have that character in its font yet."},{"title":"CD-quality sound","body":"Music CDs use 44 100 samples per second at 16 bits, in stereo (two channels). That's about 10 MB per minute."}]},{"type":"cards","id":"deeper","eyebrow":"Go deeper","title":"More than the lesson","items":[{"tag":"How it works","title":"Why 44 100 samples per second?","body":"Human hearing reaches about 20 000 Hz. To capture a wave you need at least two samples per vibration, so at least 40 000 samples a second. 44 100 gives a little extra room, which is why CDs and many audio files use it."},{"tag":"How it works","title":"Metadata","body":"Image files also store extra data about the image: width, height, colour depth, the date taken, even the GPS location of a phone photo. Social media sites often strip location data before posting, for privacy."},{"tag":"History","title":"From telegraph to emoji","body":"Before ASCII (1963) different computers used different codes, so text often turned to nonsense when moved between machines. Unicode (1991) aimed to include every writing system on Earth. Today over 98% of web pages use UTF-8, a Unicode encoding."},{"tag":"Coming next","title":"Where this leads","body":"Next you'll calculate exact file sizes and learn how compression shrinks them."}]},{"type":"cards","id":"challenge","eyebrow":"Challenge yourself","title":"Stretch your brain","intro":"Try each one before opening the card.","items":[{"tag":"Challenge","title":"A photo uses 24-bit colour. How many colours is that, and why is 24 a sensible choice?","body":"2²⁴ = 16 777 216 colours. 24 bits = 8 bits each for red, green and blue light, so each channel has 256 levels: exactly the hex colour codes from the hexadecimal lesson (#RRGGBB)."},{"tag":"Challenge","title":"Decode this ASCII message: 72 101 108 108 111","body":"72 = H, 101 = e, 108 = l, 108 = l, 111 = o.\nMessage: Hello.\nTip: small letters start at 97 (a), so 101 is the 5th letter, e."}]},{"type":"activities","id":"try","eyebrow":"Try it at home","title":"Media detective","items":[{"title":"Pixel art by numbers","time":"20 minutes","need":["Squared paper","Four coloured pencils"],"steps":["Choose 4 colours and give each a 2-bit code: 00, 01, 10, 11.","Draw an 8 × 8 picture using only those colours.","Write the grid as rows of 2-bit codes.","Give a friend only the codes and see if they can redraw it."],"why":"This is exactly how a bitmap with a colour depth of 2 is stored: 64 pixels × 2 bits = 128 bits.","safety":"No safety risks."},{"title":"Look at image properties","time":"10 minutes","need":["A computer or phone with some photos"],"steps":["Open the details or info panel of a photo.","Find its width and height in pixels and its file size.","Work out the size it would be uncompressed at 24 bits per pixel.","Compare with the real size. Why is it smaller?"],"why":"Photos are stored compressed (usually JPEG), so the real file is much smaller than width × height × 24 bits.","safety":"Don't share photos that show where you live."}]},{"type":"quiz","id":"quiz","eyebrow":"Quiz","title":"Eight more questions","questions":[{"question":"In ASCII, 'B' is 66. What is 'D'?","options":["68","67","100"],"answer":0,"right":"Correct. Codes run in alphabetical order: B 66, C 67, D 68.","wrong":"Not quite. Count on through the alphabet."},{"question":"How many bytes does \"Code 7\" use in ASCII?","options":["5","6","7"],"answer":1,"right":"Correct. C-o-d-e, the space, and 7: 6 characters.","wrong":"Not quite. Count every character, including the space."},{"question":"Why was Unicode created?","options":["To make files smaller","To replace binary","To include characters from every language"],"answer":2,"right":"Correct. ASCII only covers 128 characters.","wrong":"Not quite. Think about the world's writing systems."},{"question":"How many bits per pixel are needed for 32 colours?","options":["5","32","6"],"answer":0,"right":"Correct. 2⁵ = 32.","wrong":"Not quite. Which power of 2 is 32?"},{"question":"What is resolution?","options":["Bits per pixel","Number of pixels in the image","Colours in the palette"],"answer":1,"right":"Correct. Width × height in pixels.","wrong":"Not quite. Colour depth is bits per pixel."},{"question":"What does the sample rate measure?","options":["Bits per sample","How loud the sound is","Samples taken each second"],"answer":2,"right":"Correct. It is measured in hertz (Hz).","wrong":"Not quite. It's about how often the wave is measured."},{"question":"What happens if you increase the sample resolution?","options":["Quality and file size both go up","The sound gets louder","The file gets smaller"],"answer":0,"right":"Correct. More levels means a more accurate copy, using more bits.","wrong":"Not quite. More bits per sample means more data."},{"question":"An 8 × 8 image has a colour depth of 1 bit. How big is it?","options":["8 bits","64 bits","512 bits"],"answer":1,"right":"Correct. 64 pixels × 1 bit = 64 bits.","wrong":"Not quite. Multiply the number of pixels by bits per pixel."}]},{"type":"checklist","id":"check","eyebrow":"Self-check","title":"I can…","items":["explain what a character set is","compare ASCII and Unicode","convert characters to codes and back","explain pixels, resolution and colour depth","work out how many colours n bits per pixel can show","explain sampling, sample rate and sample resolution","describe how each setting affects quality and file size","use ord() and chr() in Python"]},{"type":"keywords","id":"words","eyebrow":"Key words","title":"Words to know","items":[{"word":"character set","meaning":"A list of characters with a binary code for each."},{"word":"ASCII","meaning":"A 7-bit character set with 128 characters."},{"word":"Unicode","meaning":"A large character set covering every language and emoji."},{"word":"pixel","meaning":"The smallest dot of colour in an image."},{"word":"bitmap","meaning":"An image stored as a grid of pixels."},{"word":"resolution","meaning":"The number of pixels in an image (width × height)."},{"word":"colour depth","meaning":"The number of bits used for each pixel."},{"word":"sampling","meaning":"Measuring a sound wave at regular intervals."},{"word":"sample rate","meaning":"How many samples are taken each second, in hertz."},{"word":"sample resolution","meaning":"The number of bits used for each sample."},{"word":"metadata","meaning":"Data about data, such as an image's size and date."}]},{"type":"sources","id":"sources","title":"Sources","items":["The Unicode Consortium: Unicode 16.0 character counts","BBC Bitesize, GCSE Computer Science: Representing images and sound","W3Techs: usage of character encodings on websites","Python documentation: ord() and chr()"]}]},"overlay":null}