{"base":{"id":"cs9-07","subject":"Programming","title":"Data types","scene":"py9","steps":[{"mode":"types","eyebrow":"Five data types","title":"Integer, real, character, string, Boolean","body":"Every value has a data type. It decides what you can do with the value: you can add integers, but not a name. Move the slider through five examples.","controls":[{"id":"i","label":"Example","min":1,"max":5,"step":1,"value":1}]},{"mode":"convert","eyebrow":"Converting types","title":"input() always gives text","body":"input() returns a string, even if the user types a number. Adding 1 to a string causes an error. Convert it with int() first. Step through.","actions":[{"id":"step","label":"Step"},{"id":"run","label":"Run"},{"id":"reset","label":"Reset"}]},{"mode":"choose","eyebrow":"Choosing a type","title":"Fit the type to the data","body":"When you design a program, choose the right type for each item of data. Look at four examples.","actions":[{"id":"c0","label":"Name"},{"id":"c1","label":"Price"},{"id":"c2","label":"Initial"},{"id":"c3","label":"Member?"}]},{"mode":"quiz","eyebrow":"Check yourself","title":"Which type?","body":"A program stores whether a light is switched on.","question":"Which data type fits best?","options":["String","Boolean","Real"],"answer":1,"right":"Correct. On or off is a True/False value.","wrong":"Not quite. Only two possible values.","look":"choose"}],"more":[{"type":"cards","id":"ideas","eyebrow":"Popular idea vs science","title":"Common mix-ups","items":[{"tag":"Popular idea","title":"\"\"7\" and 7 are the same.\"","body":"\"7\" is a string (text); 7 is an integer. \"7\" + \"7\" is \"77\"."},{"tag":"Popular idea","title":"\"Phone numbers should be integers.\"","body":"Use a string: you never do arithmetic with them, and leading zeros would be lost."},{"tag":"Popular idea","title":"\"Boolean values are the words 'yes' and 'no'.\"","body":"They are True and False, not text."}]},{"type":"cards","id":"code","eyebrow":"Python","title":"Types in action","items":[{"tag":"Integer","title":"Counting","body":"lives = 3\nlives = lives - 1","code":true},{"tag":"Real","title":"Measuring","body":"price = 2.50\ntotal = price * 3   # 7.5","code":true},{"tag":"String","title":"Text","body":"name = \"Ava\"\nprint(\"Hi \" + name)","code":true},{"tag":"Boolean","title":"Flags","body":"game_over = False\nif lives == 0:\n    game_over = True","code":true}]},{"type":"activities","id":"try","eyebrow":"Try it at home","title":"Type sort","items":[{"title":"Sorting data","time":"15 minutes","need":["Paper","Scissors"],"steps":["Write 15 items of data on slips: your age, your height in m, your name, a postcode, 'Is it raining?', a grade letter…","Sort them into integer, real, character, string and Boolean piles.","Discuss tricky ones (a postcode? a year?).","Explain each choice in one sentence."],"why":"Choosing data types is part of designing any program.","safety":"Take care with scissors."}]},{"type":"quiz","id":"quiz","eyebrow":"Quiz","title":"Six more questions","questions":[{"question":"What type is 17?","options":["Real","Integer","String"],"answer":1,"right":"Correct. A whole number.","wrong":"Not quite. No decimal point."},{"question":"What type is 0.5?","options":["Integer","Boolean","Real"],"answer":2,"right":"Correct. It has a decimal part.","wrong":"Not quite. Look for a decimal point."},{"question":"What type is \"Hello\"?","options":["String","Character","Integer"],"answer":0,"right":"Correct. Text in quotes.","wrong":"Not quite. More than one character."},{"question":"What does int(\"42\") return?","options":["The string \"42\"","An error","The integer 42"],"answer":2,"right":"Correct. It converts text to a number.","wrong":"Not quite. int means integer."},{"question":"What type is False?","options":["Boolean","String","Integer"],"answer":0,"right":"Correct. True or False.","wrong":"Not quite. Only two values."},{"question":"Which data is best stored as a string?","options":["A postcode","A score","A temperature"],"answer":0,"right":"Correct. It may contain letters and you don't calculate with it.","wrong":"Not quite. Will you do arithmetic with it?"}]},{"type":"checklist","id":"check","eyebrow":"Self-check","title":"I can explain…","items":["the five data types and an example of each","why input() needs converting with int()","how to choose a type for some data","why some numbers, like phone numbers, are stored as strings"]},{"type":"keywords","id":"words","eyebrow":"Key words","title":"Words to know","items":[{"word":"data type","meaning":"The kind of value: integer, real, character, string or Boolean."},{"word":"integer","meaning":"A whole number."},{"word":"real","meaning":"A number with a decimal part (float in Python)."},{"word":"string","meaning":"Text made of characters."},{"word":"Boolean","meaning":"A value that is True or False."}]},{"type":"sources","id":"sources","title":"Sources","items":["BBC Bitesize KS3 Computer Science","Raspberry Pi Foundation, Computing curriculum resources"]}]},"overlay":null}