Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lesson 2 Programming constructs – Algorithms – Scratch – Variables Intro.

Similar presentations


Presentation on theme: "Lesson 2 Programming constructs – Algorithms – Scratch – Variables Intro."— Presentation transcript:

1 Lesson 2 Programming constructs – Algorithms – Scratch – Variables Intro

2 COMPUTER SCIENCE Lesson 2
So what is Programming? How do our Brains work – an analysis of what we do automatically! Algorithms as sequences of instructions Introducing the 3 main programming constructs Using the SEQUENCE and SELECTION (IF) programming constructs Using Scratch to program using Sequence and IF Scratch Task

3 At the end You should know ...
What is Programming? What is an Algorithm? What are the three programming constructs!? SEQUENCE SELECTION ITERATION Using scratch to create simple programs and use programming principles How have you used TWO of the THREE constructs (SEQUENCE AND SELECTION (IF STATEMENTS) today? The use of a Variable in Scratch

4 Introduction to Programming

5 Human cells contain DNA – Have you heard of the term the GENETIC CODE?!

6 Remember Binary = Base 2 Decimal = Base 10
Quite mysteriously – the genetic CODE is just that – a CODE – a type of programming language that we find inside our cells. Can you guess what BASE it is?!?

7 Remember Binary = Base 2 Decimal = Base 10 GENETIC CODE = 4 BASES!
Can you guess what BASE it is?!? A T U G Our genes consist of various sequential combinations!!!

8 You can think of the genetic code as a language
You can think of the genetic code as a language. Each group of three bases or 'letters' forms a 'word' called a codon. Each codon specifies one amino acid, and proteins are made from long chains of amino acids. There are also codons that mark the start and end of the gene. Inspired? Well read more on the GENETIC CODE and you’ll probably find out more in BIOLOGY

9 So what is Computer Programming?
The process of developing and implementing various sets of instructions to enable a computer to do a certain task. These instructions are considered computer programs and help the computer to operate smoothly. The language used to program computers is not understood by an untrained eye. Computer programming continues to be a necessary process as the Internet continues to expand. more: 

10 What is a Computer Program
A computer program (also software, or just a program) is a sequence of instructions written to perform a specified task with a computer. FYI A Computer Virus = is just a nasty little computer program (a bit of a code that does something BAD!)

11 A computer programmer basically thinks about and then types loads of clever instructions to CREATE something In mathematics and computer science, an algorithm is an effective method expressed as a finite list of well-defined instructions. In simple words an algorithm is a step-by-step list of instructions (that tell a program what to do)

12 The 3 main programming constructs
Any programmer needs to know about the following three things. In this lesson We will only be looking at the first two. SEQUENCE (basically a sequence or set of instructions put in order) SELECTION (IF STATEMENTS and CASE Statements. We will only be looking at the first one in this session) ITERATION (these are loops – there are 3 main types (FOR loops, While – Next and Repeat – Until LOOPS - - More on these later)

13 Very very clever people in the early days of computing realised that they could use a special number system called BINARY Binary is a language of 1

14 Two type of Programming
Ways we communicate with computers LOW LEVEL (Binary / Assembly Language) HIGH LEVEL Languages (like Java, VB, Scratch)

15 Remember that all a computer can really understand is BINARY (1s and 0s)
This means that ultimately all code (high level language code) needs to be CONVERTED into Binary. This is done by means of COMPILERS, INTERPRETERS and TRANSLATORS These are computer programs that are used to convert high level instructions or language into a form that can be understood by the computer. (Binary) Read more:

16 TRANSLATORS! The idea of using a computer to TRANSLATE human like language to machine language was first suggested by Grace Hopper (in 1952) She is often credited with the title of being the world’s first FEMALE PROGRAMMER!

17 Let’s Analyze the Programming
Constructs in use

18 SELECTION: IF STATEMENTS
See if you can find: SEQUENCE SELECTION: IF STATEMENTS ITERATION: LOOPS The use of a VARIABLE

19 But what, really is a program?
-A Sequence of Instructions And what is a variable?

20 Algorithms – (in our brain)
HOW OUR BRAINS WORK Algorithms – (in our brain) We eat, drink, speak, respond and appear to have been pre-programmed to do so. There is ‘Free Will’ too, but that’s a more philosophical discussion. DEFINITION: Algorithm = sequence of instructions which performs a meaningful task

21 How our brains work Input Processing Output
We don’t often realize it but our brains are pretty awesome. The brain is storing values and processing data (as well as producing outputs) all the time Think of any system as comprising of these 3 parts Input Processing Output

22 Inputs need to be “stored”
And this is where “Variables” come in. Variables are about allocating a little memory space to store a value.

23 What is a Variable? A storage box for Values 26
Name of Box [Variable] =Age 26 A storage box for Values

24 What is a Variable? All variables must be declared before they are used in a program

25 When I give you two numbers your brain stores it automatically…
15 47 Number 1 Number 2 You don’t consciously say – “right, now I am going to store number 1 and assign it a value of 15 and number 2 and assign it a value of 47…” it just happens instantly!”

26 In a computer you need to declare variables ….
Example of declaring variables in VB Num1=15 Num2 =47 15 47 Number 1 Number 2 Think of it like a block of space (MEMORY ALLOCATION) for the inputs You are going to be processing

27 TASK Write a paragraph about why coding is important. Could computers work without code? If you wrote your own code to solve a problem, what problem would you want to fix? Take the next 5-10 minutes to write your reflective paragraph.

28 A little more on Algorithms
Pseudocode or Flow Charts are often used to show the structure and functionality of a program. In Pseudocode the individual actions to be carried out by the program are stated in plain English … they can be visually represented in a Flow Chart using symbols and arrows.

29 Sample Pseudocode or Flowchart
Pseudocode – is like “fake” code – resembles English in this case. READ NUMBER1 READ NUMBER 2 IF NUM 1 > NUM 2 Then ADD NUMBERS PRINT THE SUM Read Number 1 Read Number 2 No Num 1 > Num 2? Yes Add Numbers Print the Sum

30 Closing thought! In pairs discuss a few things you thought were interesting about this lesson. Talk about potential careers you could peruse if you became a computer programmer. Be ready to answer if called on!


Download ppt "Lesson 2 Programming constructs – Algorithms – Scratch – Variables Intro."

Similar presentations


Ads by Google