{"base":{"id":"cs9-09","subject":"Programming","title":"Working with strings","scene":"py9","steps":[{"mode":"strfns","eyebrow":"String functions","title":"Length and case","body":"len() counts the characters in a string, including spaces. upper() and lower() change the case. Try three strings.","actions":[{"id":"w0","label":"\"Sri\""},{"id":"w1","label":"\"Hello World\""},{"id":"w2","label":"\"python\""}]},{"mode":"strcmp","eyebrow":"Comparing answers","title":"YES, Yes or yes?","body":"\"YES\" == \"yes\" is False, because capitals are different characters. Converting with lower() first makes the comparison work whatever case the user types.","actions":[{"id":"a0","label":"User types yes"},{"id":"a1","label":"User types YES"},{"id":"a2","label":"User types Yes"},{"id":"run","label":"Run"}]},{"mode":"validate","eyebrow":"Checking input","title":"Is the name long enough?","body":"A program can use len() to check a name has 2 to 12 letters before accepting it. Try three names.","actions":[{"id":"n0","label":"\"Al\""},{"id":"n1","label":"\"Mia\""},{"id":"n2","label":"\"A\""},{"id":"run","label":"Run"}]},{"mode":"quiz","eyebrow":"Check yourself","title":"Length","body":"word = \"Hi there\"","question":"What is len(word)?","options":["7","8","2"],"answer":1,"right":"Correct. H, i, space, t, h, e, r, e: the space counts.","wrong":"Not quite. Count every character, including the space.","look":"strfns"}],"more":[{"type":"cards","id":"ideas","eyebrow":"Popular idea vs science","title":"Common mix-ups","items":[{"tag":"Popular idea","title":"\"Spaces don't count in len().\"","body":"Spaces are characters, so they count."},{"tag":"Popular idea","title":"\"upper() changes the original string.\"","body":"It returns a new string; you must store it: name = name.upper()."},{"tag":"Popular idea","title":"\"\"Yes\" == \"yes\" is True.\"","body":"Capital Y and small y are different characters."}]},{"type":"cards","id":"code","eyebrow":"Python","title":"String tools","items":[{"tag":"Length","title":"len","body":"len(\"cat\")   # 3","code":true},{"tag":"Case","title":"upper / lower","body":"\"Ava\".upper()   # \"AVA\"\n\"Ava\".lower()   # \"ava\"","code":true},{"tag":"Compare","title":"Ignore case","body":"if answer.lower() == \"yes\":\n    print(\"OK\")","code":true}]},{"type":"activities","id":"try","eyebrow":"Try it at home","title":"Password checker","items":[{"title":"Plan a checker","time":"20 minutes","need":["Paper or a computer"],"steps":["Plan a program that asks for a password.","Reject it if len() is less than 8.","Ask 'Show password? (yes/no)' and accept YES, Yes or yes.","Test it with five different inputs."],"why":"len() and lower() are used in real sign-up forms.","safety":"Never type your real password into a test program."}]},{"type":"quiz","id":"quiz","eyebrow":"Quiz","title":"Six more questions","questions":[{"question":"len(\"computer\") = ?","options":["7","9","8"],"answer":2,"right":"Correct. Eight letters.","wrong":"Not quite. Count them."},{"question":"\"Shalo\".upper() = ?","options":["\"SHALO\"","\"shalo\"","\"Shalo\""],"answer":0,"right":"Correct. All capitals.","wrong":"Not quite. upper means capitals."},{"question":"\"MAP\".lower() = ?","options":["\"MAP\"","\"Map\"","\"map\""],"answer":2,"right":"Correct. All small letters.","wrong":"Not quite. lower means small letters."},{"question":"Why use .lower() before comparing answers?","options":["To make it faster","So any case matches","To remove spaces"],"answer":1,"right":"Correct. YES, Yes and yes all become yes.","wrong":"Not quite. Different capitals."},{"question":"A name must be 2 to 12 characters. Which is rejected?","options":["\"B\"","\"Bo\"","\"Benjamin\""],"answer":0,"right":"Correct. Only 1 character.","wrong":"Not quite. Use len()."},{"question":"len(\"  \") (two spaces) = ?","options":["0","2","1"],"answer":1,"right":"Correct. Spaces are characters.","wrong":"Not quite. Do spaces count?"}]},{"type":"checklist","id":"check","eyebrow":"Self-check","title":"I can explain…","items":["how len() counts characters","how upper() and lower() change case","why converting case makes comparisons consistent","how to check the length of an input"]},{"type":"keywords","id":"words","eyebrow":"Key words","title":"Words to know","items":[{"word":"string","meaning":"A sequence of characters."},{"word":"character","meaning":"A single letter, digit, space or symbol."},{"word":"len()","meaning":"Gives the number of characters."},{"word":"case","meaning":"Whether letters are capitals or small."},{"word":"validation","meaning":"Checking that input is sensible."}]},{"type":"sources","id":"sources","title":"Sources","items":["BBC Bitesize KS3 Computer Science","Raspberry Pi Foundation, Computing curriculum resources"]}]},"overlay":null}