Programming 101 Study materials -- Copyright 2015 Usmar A. Padow (amigojapan) usmpadow@gmail.com
Part 1 programming basics done in Scratch



lesson 1

-lightbot (a programming game)
Learn the basics of programming
Procedural instructions
Click here to play lightbot

-Scratch
Note: I am a dyslexic, so if you find spelling mistakes, please bear with it... they don't really affect the programs themselves

Note: this is not a tutorial on how to use scratch, it is an introduction to programming that happens to use scratch as a tool to make it easy to get used to the basics of programming(while avoiding certain problems called "syntax errors" and "compiler errors"). We will not go into depth on how to use Scratch itself

Note: Completed exercise projects are marked with a **, it is not recommended you click “look inside" until after you finish making them yourself but you may execute the program to see what the output should be like.

Note: if you finished your project before others you will become a "deputy teacher" and help the others understand what they are doing. But don't do their work for them please.

Note: make your own Scratch account so you can save your work on the cloud
Note: when you are ready to write your own solution to a problem, either click onSolve problem online or use the scratch offline editor which you can download by clicking here

Input/Output
(we will touch on string handling(string concatenation))


Run program
View source



Run program
View source



Variables


Run program
View source



Operators > = <
Conditional(if/else),


Run program
View source



AND and OR logical operators



Refference this please View source



Tasks:
Write hello world
Write a greeting program “hello your name”
Write a program that asks for a username *and* password *or* password2
Write a program with > < telling you to wear a coat or sun screen
Write Body mass index
Run program
Solve problem online
** View source




formula BMI =weight/(height*height)
Category BMI range – kg/m2 BMI Prime
Very severely underweight less than 15 less than 0.60
Severely underweight from 15.0 to 16.0 from 0.60 to 0.64
Underweight from 16.0 to 18.5 from 0.64 to 0.74
Normal (healthy weight) from 18.5 to 25 from 0.74 to 1.0
Overweight from 25 to 30 from 1.0 to 1.2
Obese Class I (Moderately obese) from 30 to 35 from 1.2 to 1.4
Obese Class II (Severely obese) from 35 to 40 from 1.4 to 1.6
Obese Class III (Very severely obese) over 40 over 1.6

extra task:
Write a blood pressure program

lesson 2

-Scratch
loops(repeat/repeat until), counter



you may reference View source


Tasks:
Make a program that draws a square
Make a program that draws 4 squares
Make a program that makes the number of squares indicated by the user

lesson 3
Random number generator

tasks:
Write the “guess my number” game


Run program
Solve problem online
** View source




Write a program that plays rock paper scissor
Run program
Solve problem online
** View source





Lesson 4

Exercise day 1

Write a calculator
Run program
Solve problem online
** View source



Write a Memory game “flash a number, remember it, and then input it"
Run program
Solve problem online
** View source




lesson 5
Lists

Write a program that is an address book(using lists)
Run program
Solve problem online
** View source




Algorithms
An Algorithm is a set of step-by-step instructions that work towards achieving a specific goal or solving a problem
the difference between an algorithm and a program is that a program is coded for a computer to follow, and an algorithm can be followed by a person…. I am thinking of bringing a set of cards and have the students sort them using insertion-sort
every program is an algorithm.
for example, a cooking recipe is an algorithm. lets now sort a deck of cards using insert sort.

Computer Science focuses more on algorithms than Software Engineering does.
The Sort algorithms
http://wiki.scratch.mit.edu/wiki/Sorting_Values

Lesson 6

String handling
get the first letter of a string


View source


input a phrase and get the first and last words of a sentence
get the phrase, count the spaces, count the words, get the position of the first and last space in the phrase, concatenate the letters of each word to itself to make the words
Run program
Solve problem online
** View source


Write a program that gets the nth word in a sentence
Run program
Solve problem online
** View source


International Morse code
A.- B-... C-.-. D-.. E. F..-. G--. H.... I.. J.--- K-.-
L.-.. M-- N-. O--- P.--.
Q--.- R.-. S... T- U..- V...-
W.-- X-..- Y-.-- Z—..
make spaces be / and a longer wait(no sound)
Write a program that converts English to Morse code
Run program
Solve problem online
** View source




Write a program that converts Morse code to English
.... . .-.. .-.. --- / .-- --- .-. .-.. -.. should be "hello world"
Run program
Solve problem online
** View source


Now modify the first program so that it plays out the message in sounds.

lesson 7
functions(blocks)
Why Functions?
Make your code more readable, by braking it into blocks
You can reuse code: Define the code once, and use it many times.
You can use the same code many times with different arguments, to produce different results.
When you are writing a program and you seem to be repeating stuff, it should be a function.

Examples:
Add function
Run program
View source
A fraction simplifier that used the greatest common divisor function
Run program
View source

Write a calculator that uses functions to do its calculations
Solve problem online
Write a program that plays hangman
Your main loop should look like this:

Run program
Solve problem online
** View source