Programming - PowerPoint PPT Presentation

1 / 47
About This Presentation
Title:

Programming

Description:

... 1_Fun Clip Microsoft Word Document Programming & Scratch Programming Problem-Solving and Project-Design Skills Fundamental Ideas about Computers and ... – PowerPoint PPT presentation

Number of Views:33
Avg rating:3.0/5.0
Slides: 48
Provided by: Richar1017
Category:

less

Transcript and Presenter's Notes

Title: Programming


1
Programming Scratch
2
Programming
  • Learning to program is ultimately about learning
    to think logically and to approach problems
    methodically.
  • The building blocks out of which a programmer
    constructs solutions, meanwhile, are relatively
    simply.

3
Problem-Solving and Project-Design Skills
  • logical reasoning
  • breaking complex problems into simpler parts
  • debugging problems
  • developing ideas from initial conception to
    completed project
  • sustained focus and perseverence

4
Fundamental Ideas about Computers and Programming
  • computer programs tell the computer precisely
    what to do, step-by-step
  • writing computer programs doesnt require special
    expertise, just clear and careful thinking

5
Programming
  • Common in programming, for instance, are "loops"
    (whereby a program does something multiple times)
    and "conditions" (whereby a program only does
    something under certain circumstances. Also
    common are "variables" (so that a program, like a
    mathematician, can remember certain values).

6
Statements
  • In programming, a statement is simply a directive
    that tells the computer to do something. Think of
    it as a command or an instruction. In Scratch,
    any block whose label reads like a command is a
    statement.

7
Statements
  • One such block instructs a sprite to say
    something

8
Statements
  • Another such block instructs a sprite to go to
    some location

9
Sequence
  • To create a program in Scratch, you need to think
    systematically about the order of steps

10
Boolean Expression.
  • In programming, a Boolean expression is an
    expression that is either true or false. In
    Scratch, any block shaped like an elongated
    diamond is a Boolean expression.
  • One such block is

11
Boolean Expression.
  • Another such block is
  • After all, it is either true that some number is
    less than another number or it is false.

12
Boolean Logic
  • and, or, or not are examples of boolean logic.

13
Conditions
  • In programming, a condition is something that
    must be true in order for something to happen. A
    condition is thus said to "evaluate to true" or
    "evaluate to false." In Scratch, any block whose
    label says "if," "when," or "until" is a sort of
    conditional construct.

14
Conditions
  • One such block is

15
Conditions
  • The previous construct is generally known as an
    "if construct." With it can we instruct a sprite
    to say hello only if, say, the user has depressed
    the mouse button

16
Conditions
  • A related construct is the "if-else construct"

17
Conditions
  • With the previous construct can we instruct a
    sprite to say hello or goodbye, depending on
    whether the user has depressed the mouse button

18
Conditions
  • Realise that these constructs can be nested to
    allow, for example, for three different
    conditions. This construct could be called an
    "if-else if-else construct".

19
Conditions
  • Another conditional block is
  • Yet another such block is

20
Conditional Statements
  • if, forever-if, if-else repeat-until and
    waituntil check for a condition

21
Loops
  • Sometimes, you want one or more statements to be
    executed multiple times in a row. To implement
    this behavior, we turn our attention to loops.

22
Loops
  • In programming, a loop can induce multiple
    executions of statements. In Scratch, any block
    whose label begins with "forever" or "repeat" is
    a looping construct.

23
Loops
  • One such block is
  • This construct allows us, for instance, to
    instruct a sprite to meow every other second

24
Loops
  • Another block allows you to loop a specific
    number of times
  • And another block allows you to loop until some
    condition is true

25
Iteration (Looping)
  • forever and repeat can be used for iteration
    (repeating a series of instructions)

26
Variables
  • Sometimes, you want execute some statement
    multiple times, each time varying your behavior
    ever so slightly. We thus turn our attention to
    variables.

27
Variables
  • In programming, a variable is a placeholder for
    some value.
  • Variables allow us, for instance, to instruct a
    sprite to count up from 1

28
Variables
  • A variable that only takes on a value of true
    (i.e., 1) or false (i.e., 0), incidentally, is
    called a Boolean variable.

29
Variables
  • The Variables category allows you to create a new
    variable and use it in a program.

30
Threads
  • In programming, a thread is like a mini-program
    within a program that can execute at the same
    time as other threads.
  • One such block is

31
Threads
  • It's often helpful to use separate threads for
    conceptually distinct tasks. For instance, you
    might want to keep track of whether the user ever
    presses some key during a program's execution in
    order to, say, toggle sound on and off

32
Threads
33
Threads
  • Notice how, in the above, the left-hand thread
    handles meowing, if appropriate, whereas the
    right-hand thread constantly checks and remembers
    whether the user has muted or unmuted sound by
    pressing space'.

34
Threads (Parallel Execution)
  • Launching two stacks at the same time creates two
    independent threads that execute in parallel.

35
Events
  • In programming, multiple threads can communicate
    with each other by signaling events and handling
    events. An event, then, is like a message from
    one thread to another.
  • A block that signals an event is

36
Events
  • A block that handles an event is

37
Events
  • Not only can events be signaled by blocks, they
    can also be signaled by a user's actions.
    Clicking Scratch's green flag, for instance,
    effectively signals an event that is handled by

38
Events
  • In Scratch, not only do events enable threads to
    communicate, they also allow sprites to
    communicate with each other.

39
Event Handling
  • when key pressed and when sprite clicked are
    examples of event handling responding to events
    triggered by the user or another part of the
    program

40
Synchronisation
  • broadcast can coordinate the actions of multiple
    sprites.
  • For example, Sprite1 sends the message winner
    when condition is met

41
Synchronisation
  • This script in Sprite2 is triggered when the
    message is received

42
Real-Time Interaction
  • mouse_x, mouse_y, and loudness can be used as
    dynamic input for real-time interaction

43
Time Triggering
  • Scratch includes an internal clock that you can
    access with timer.

44
Random Numbers
  • The pick random block selects random integers
    within a given range.

45
Object-Oriented Programming
  • Each sprite can have its own scripts and data.

46
User Interface Design
  • You can design interactive user interfaces in
    Scratch for example, using clickable sprites to
    create buttons.

47
Data Types
  • Different data types (such as numbers and
    booleans) are represented by different shapes in
    Scratch
Write a Comment
User Comments (0)
About PowerShow.com