Essay about Programming concepts

Submitted By numb8
Words: 1199
Pages: 5

CPSC 101/WMST 201: Connecting with
Computer Science

Module 4: Processes
Recipes from Scratch

Module 4.2: Recipes and variables
Here is a recipe for Jello Instant Pudding
1. put 3 cups of milk in a bowl
2. add entire contents of package
3. whisk for 2 minutes
4. transfer to serving bowls
5. let stand for 3-5 minutes
6. serve!

CPSC 101 – 2012W T1

2

Module 4: Processes
Learning Goals: at the end of this module, you will be able to: recognize and explain the five essential properties of an algorithm: input specified output specified definiteness effectiveness finiteness CPSC 101 – 2012W T1

3

Module 4: Processes
Learning Goals (continued) recognize and explain the concepts of sequences of instructions, variables, loops, functions, conditional statements, and arrays

in short programs specified in a programming language such as JavaScript, or in other clearly expressed processes (which may or may not be computer related)
CPSC 101 – 2012W T1

4

Module 4: Processes
Learning goals (continued): determine, simulate and explain how short programs or program fragments work make small modifications to short program fragments to achieve clearly specified tasks explain and simulate simple algorithms for fundamental problems such as searching and sorting

CPSC 101 – 2012W T1

5

Module 4: Processes
Module Outline
Programs and algorithms.
Recipes and variables.
Loops.
Functions.
Conditional statements.
Arrays.

CPSC 101 – 2012W T1

6

Module 4.1: Programs and algorithms
Exercise: write an algorithm for making a peanut butter and jam sandwich. Your algorithm can use: peanut butter sliced bread jam knife spoon plate

CPSC 101 – 2012W T1

7

Module 4.1: Programs and algorithms

? Did your group succeed in getting a proper sandwich made?
a) Yes, right away.
b) Yes, after 1-2 revisions to the instructions
c) Almost.
d) No.

CPSC 101 – 2012W T1

8

Module 4.1: Programs and algorithms

? What was the main point you took away from the exercise? a) Making sandwiches is hard.
b) Humans are smart.
c) Specifying a process precisely is hard.
d) Carrying out precise instructions is hard.

CPSC 101 – 2012W T1

9

Module 4.1: Programs and algorithms
Processes (programs, algorithms) are everywhere allow us to make computers and people do things they otherwise couldn’t.

you come up with 3
? Canprimarily meant to beexamples of “programs” not executed by computers?

CPSC 101 – 2012W T1

10

Module 4.1: Programs and algorithms
Jumping in at the deep end:
Processing: Depth
Scratch: Dancing triangles

[processing.org]
[scratch.mit.edu]

Don’t Panic!
It’s OK to not understand parts of a program
Web search can help
Experimentation aids understanding

CPSC 101 – 2012W T1

11

Module 4.1: Programs and algorithms
Fundamental concepts:
Instructions (input, output, drawing, math, …)
Sequences of instructions
Variables
Loops / repetition (repeat, until, while, for)
Procedures / functions
Conditional statements (if, else)
Arrays

CPSC 101 – 2012W T1

12

Module 4: Processes
Module Outline
Programs and algorithms.
Recipes and variables.
Loops.
Functions.
Conditional statements.
Arrays.

CPSC 101 – 2012W T1

13

Module 4.2: Recipes and variables
Here is a more interesting recipe for Duck breast with Seville orange & savoy cabbage http://www.bbcgoodfood.com
Ingredients (for 4):
4 duck breasts
1 large Seville orange, zested and juiced
2 tbsp honey
2 cloves
1 cinnamon stick chicken stock fresh, cube or concentrate, made up to 300ml
1 savoy cabbage, quartered, heart removed and shredded butter mashed potato, to serve
CPSC 101 – 2012W T1

14

Module 4.2: Recipes and variables
Duck breast recipe (continued)
Preparation:
1. Heat a non-sticking frying pan.
2. Put in the duck breasts, skin side down, then turn down the heat and leave for 10 minutes until the fat on the duck