Presentation is loading. Please wait.

Presentation is loading. Please wait.

Box Variables Prof Paul Curzon Queen Mary, University of London With support from Google, D of.

Similar presentations


Presentation on theme: "Box Variables Prof Paul Curzon Queen Mary, University of London With support from Google, D of."— Presentation transcript:

1 Box Variables Prof Paul Curzon Queen Mary, University of London www.teachinglondoncomputing.org Twitter: @TeachingLDNComp With support from Google, D of E and the Mayor of London

2 Aims Give you deeper understanding of core topics –Getting started programming –Variables: declaration and initialisation –Assignment –Sequencing and flow of control Give you practical ways to teach computing in a fun, thought provoking way –away from computers, focus on concepts Linked activity sheets and booklets can be downloaded from our website: www.teachinglondoncomputing.org

3 Variables and assignment One of the first big hurdles students face when learning to program is understanding how variables and assignment work. If they do not understand this they will not get any further. It is very easy to misunderstand! It is very easy to fix!

4 Running programs physically A really good way to build a deep understanding of programming constructs is to act out the program Compile the program on to people! They follow the instructions Makes abstract ideas visible and tangible

5 Variables as boxes Variables are like storage boxes Special ones that can –Store –Create –Destroy

6 A swap program What does this (python) program do? colour1 = “red” colour2 = “green” temp = colour1 colour1 = colour2 colour2 = temp Let’s act it out!

7 Main points The main points this activity illustrates are: Variables have names –so the computer knows which one is meant. Variables hold values – the actual data that is being stored. Do not confuse variable names with their values! A variable can only store one value at a time. When accessing a variable’s value you make a copy –that variable’s value is untouched. When you store a value in a variable you destroy anything that was previously there.

8 Is this a swap program? What does this program do? colour1 = “red” colour2 = “green” colour1 = colour2 colour2 = colour1

9 Paper dry run As a follow up exercise dry run simple programs on paper Make sure everyone understands Fix anything anyone has misunderstood

10 Faulty mental models(1) Watch out for the following common misunderstandings: X a variable still holds its original value after an assignment, X assignment works by copying left to right, X a sequence of assignments all happen together X a sequence of assignments can happen in any order

11 Faulty mental models(2) Watch out for the following common misunderstandings: X both left hand side and right hand side change X assignment is like a mathematical equality just making both sides the same X after an assignment future changes to one variable change the other X variable can hold all the values ever assigned to it

12 Summary Variables and assignment are key early topics Important to –get the mental model right –fix if not! Programming can be introduced in fun ways away from a computer

13 More support On our website to support this session: Activity sheets Story sheets Slides Details of more worskshops/courses free unplugged sessions subsidised courses (e.g. GCSE programming) www.teachinglondoncomputing.org Twitter: @TeachingLDNComp

14 Thank you! Together we are Teaching London Computing www.teachinglondoncomputing.org Twitter: @TeachingLDNComp


Download ppt "Box Variables Prof Paul Curzon Queen Mary, University of London With support from Google, D of."

Similar presentations


Ads by Google