Android/GogoTraining/Introduction to Programming for Non-Programmers

From Omnia
Jump to navigation Jump to search

Description

"If you are interested in getting into a programming then Introduction to Programming for Non-Programmers is a good place to start. People who like to program tend to be people who have a problem-solving mindset. In this course you can test your problem-solving abilities and determine if programming is the right career for you. This course is designed specifically for individuals who are interested in starting a career in programming and presents programming skills to the non-programmer. By the end of the course you will be writing simple programs, understand the basics of programming and have a good idea if programming is the career for you. You will also be prepared to start taking more traditional programming languages classes."

Objectives

As a result of taking this course, you will be able to:

  • Write scripts to manipulate graphics objects on the screen
  • Collect input from the user and make decisions based on that input
  • Communicate between separately running scripts
  • Perform math calculations and do comparisons

Outline

Module 00: Introduction to Programming for Non-Programmers - Course Introduction

Module 01: Getting Started

  • Programming Concepts
  • Types of Languages
  • What Makes a Good Programmer?
  • Demo: Installing the Scratch Environment

Module 02: A Tour of Scratch

  • Basic Areas
  • Sprites
  • How to Build a Scratch Script
  • Comments
  • Workshop

Module 03: More Scratch Features

  • Costumes
  • Backgrounds
  • Help Features
  • 3 Types of Scratch Blocks
  • Workshop

Module 04: Problem Solving

  • Math, Movement and Puzzle Problems
  • Basic Steps in Problem Solving
  • Algorithms
  • Scratch Cards
  • Workshop

Module 05: Variables, Operators and Input

  • Creating and Using Variables
  • Mathematical Operators
  • Asking Questions and Getting Answers
  • Using Answers in Control Blocks
  • Workshop

Module 06: Threads and Tying It All Together

  • Threads
  • Broadcasting
  • Workshop
  • Comparison of Scratch Programs to C
  • Review

00: Introduction to Programming for Non-Programmers - Course Introduction

Scratch - http://scratch.mit.edu/

Scratch 1.4 Download - http://info.scratch.mit.edu/Scratch_1.4_Download

01: Getting Started

Programming Languages

"Low level" languages

  • interact with hardware directly
  • example: assembler
  • code specific to the processor
  • example: C (more portable than assembler)

"High level" languages

  • closer to human language
  • more restrictions (intentional)
  • one statement in high level equals many statements of a "low level" language
  • c++, java

"Very High Level" languages:

  • Ruby, Python

Object-Oriented Languages:

  • c++
  • classes of objects

Scripting Languages:

  • interpreted
  • perl, python

Scratch

Scratch - http://scratch.mit.edu/

Developed by MIT Media Lab

  • Visual programming language

Rather than using lines of code, programs are built with "building blocks"

Scratch download - http://scratch.mit.edu/download

Programming concepts of scratch:

  • iterations (loops)
  • decision making (if, if-else)
  • numbers and names (variables, lists)
  • advanced:
    • threads
    • events

Scratch Panels:

  • Blocks Palette - motion, looks, sound, etc
  • Scripts Area - where blocks are scripted
  • Stage - clicking green flag will run program on the stage
  • Sprite List - graphics character

Snap blocks together

Use the "green" flag block, in the control block palette, as a starting block for scripts

Scratch's website has many existing projects that can be used, and a number of tutorials

02: A Tour of Scratch

Scratch tools

scratch cat - sprite

Those who programming in Scratch are called "Scratchers"

scratch environment:

  • stage
  • blocks palette
  • script area
  • sprites

drag blocks from block palette to script area - building blocks for scripts

snap (attach) blocks together to build scripts

can double click on a placed block(s) (in script area) to cause to happen now

blocks:

  • movement blocks - can be absolute or relative
  • looks - change size and color of sprite
  • sound - audio sounds for your sprite
  • pen - drawing on screen
  • events - triggers
  • control - start, loops, wait
  • sensing - ask questions, check states
  • operators - math
  • variables - contains a value that can be manipulated

strings - sequence of characters

scripts are tied to sprites - each will have their own

Hello World

say [Hello world]

Sample Scripts:

when [up arrow] key pressed
point in direction [90]
move [10] steps
forever
  move [10] steps
  turn [right] [15] degrees
  play sound [meow]
  wait [1] secs

Gravity Cat:

when [flag] clicked
go to x:[0] y:[0]
clear
pen down
set [vx] to 1
set [vy] to 4
forever
  change x by [vx]
  change y by [vy]
  if [y position] < [-200] then
    set [vy] to [-30]
  if [y position] < [-200] or [y position] > 400 then
    set [vy] to [-1] * [vy]
  if [x position] < [-200] or [x position] > 200 then
    clear
    set [xy] to [-1] * [xy]
  change [vy] by [-0.9]

Comments

  • right click and select "add comment"
  • can be added to script space or specific block

Project Notes - comments for whole project

  • found under "project page"

scenes - ?

03: More Scratch Features

Sprite control

Sprite rotation style:

    • 365 rotation
    • left-right rotation only
    • no rotation

Sprite costumes:

  • change in appearance (think motion frames)

Sprite sounds:

  • sounds associated with sprite

Sprite tools:

  • duplicate
  • delete
  • grow
  • shrink

Background:

  • good background while programming: "xy-grid"
  • can have multiple backgrounds to rotate through

Help

  • right click on block and select help
  • shows usage and example

Types of blocks:

  • Stack blocks - blocks with puzzle piece connectors, that can be snapped together (eg. move steps, if, loops)
  • Hat blocks (hats) - placed on top of stack - wait for something to happen (eg. start flag)
  • Reporter blocks - oval (return value) or pointed ends (return true/false) (eg. mouse x, mouse down?)
    • Checkbox - oval reporter blocks can be displayed on screen by clicking checkbox

04: Problem Solving

puzzles and brain teasers

algorithm - "step-by-step procedure for solving a problem or accomplishing some end, especially by a computer" -- Merriam-Webster

Scratch Cards - have programming problems for you to solve

05: Variables, Operators and Input

Variables - areas in memory that store things

Variables can be created globally for "all sprites" or locally for "this sprite only".

Operators are math functions in the pointy edge blocks.

Input can be received by using the "ask" block.

06: Threads and Tying It All Together

Threads are scripts running in parallel.

Can communicate between threads

  • broadcast
  • when I receive

Can be used to synchronize several scripts